Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🪟 powershell support #124

Closed
Satanarious opened this issue Apr 26, 2024 · 13 comments
Closed

🪟 powershell support #124

Satanarious opened this issue Apr 26, 2024 · 13 comments
Assignees
Labels
feature New feature or request

Comments

@Satanarious
Copy link

So far there is Linux and Unix support, there is windows support but not for Powershell. Any plans on supporting powershell in the future?

@ohitstom
Copy link

please mommy support powershell~

@Delusoire
Copy link

+1
Having a mother figure on PowerShell could make Windows just a tad more bearable

@FWDekker FWDekker self-assigned this Apr 26, 2024
@FWDekker FWDekker added the feature New feature or request label Apr 26, 2024
@FWDekker
Copy link
Owner

i don't want to add explicit powershell support because that would mean i would have to write an entire new script, since powershell cannot run posix (.sh) scripts. i don't use windows myself and have never used powershell scripts, so that would be extremely hard to develop and test.

however, if you have (1) linux subsystem or (2) cygwin or (3) git for windows installed, you can just run the posix script inside there. if you have sh or bash on your path, you can even run sh mommy.sh inside powershell, so using mommy through those external programs in powershell should be feasible. i'll see if i can find a way to get that all linked up together, and will add that to the readme :-)

@FWDekker FWDekker changed the title Powershell Support 🪟 powershell support Apr 26, 2024
@Satanarious
Copy link
Author

I think the git one would be the most preferable for most.

FWDekker added a commit that referenced this issue May 5, 2024
@FWDekker
Copy link
Owner

FWDekker commented May 5, 2024

i've added instructions on how to use mommy in powershell through either wsl or through git bash. let me know if they work for you and if they're clear enough :-)

@Satanarious
Copy link
Author

function prompt {"$(& sh mommy -1 -s $([int][bool]::Parse(!$?)))> " }

Somehow this works for me and not what you mentioned in the readme. Given that I have sh.exe and mommy in PATH

@Satanarious
Copy link
Author

Satanarious commented May 6, 2024

I don't need the function if I use Oh-My-Posh.
Leaving this Oh-My-Posh theme block in case anybody needs it.

{
      "type": "rprompt",
      "segments": [
        {
          "type": "command",
          "style": "diamond",
          "foreground": "#ffffff",
          "background": "#00897b",
          "leading_diamond": "\ue0b2",
          "trailing_diamond": "\ue0b4",
          "properties": {
            "shell": "bash",
            "command": "mommy"
          }
        }
      ]
}

@FWDekker
Copy link
Owner

FWDekker commented May 6, 2024

function prompt {"$(& sh mommy -1 -s $([int][bool]::Parse(!$?)))> " }

Somehow this works for me and not what you mentioned in the readme. Given that I have sh.exe and mommy in PATH

interesting! thanks for reporting that. i found two mistakes in my code: i wrapped only the mommy executable into quotes instead of the entire command (up to and including the Parse(!$?) part) (but as you showed, i can also omit the -c and let the command be split), and i used backwards slashes in the path to mommy. i'll fix that in a jiffy. can you confirm that the following works correctly in powershell (correcting the paths as needed, of course):

function prompt { "$(& "C:\Program Files\Git\bin\sh.exe" "C:/Users/username/mommy" -1 -s $([int][bool]::Parse(!$?)))> " }

it works for me, but having someone else confirm it would be nice :-)

as for the oh-my-posh config, thank you for that! i hadn't really looked into it myself, i just knew it existed. do you mind if i include that in the readme? either way i'll add you to the acknowledgements (unless you don't want that) :D

@Satanarious
Copy link
Author

function prompt {"$(& sh mommy -1 -s $([int][bool]::Parse(!$?)))> " }

Somehow only the above code works for me but not if I enter the path manually, as you mentioned in the comment above.
About the oh-my-posh config, you can feel free to include it in your readme. I cannot take credit because I ripped it of MS-Copilot and just made some changes.

@FWDekker
Copy link
Owner

FWDekker commented May 6, 2024

thanks for trying it out. any chance it's due to missing quotes around spaces? if sh is in C:\Program Files\Git\bin\sh.exe, you have to write "C:\Program Files\Git\bin\sh.exe", and similarly so for mommy. could that be the issue?

either way, i think the issue itself is closed, but feel free to reply here with further comments or remarks :-)

@Satanarious
Copy link
Author

I'm using quotes like you mentioned. But it still doesn't work with manual paths on my end.

@ziasquinn
Copy link

Can't get this to function in my oh my posh but I'm probably missing something stupid.

I don't need the function if I use Oh-My-Posh. Leaving this Oh-My-Posh theme block in case anybody needs it.

{
      "type": "rprompt",
      "segments": [
        {
          "type": "command",
          "style": "diamond",
          "foreground": "#ffffff",
          "background": "#00897b",
          "leading_diamond": "\ue0b2",
          "trailing_diamond": "\ue0b4",
          "properties": {
            "shell": "bash",
            "command": "mommy"
          }
        }
      ]
}

Can't get this function in my oh-my-posh, but maybe it's because I'm missing something obvious? I have git bash and sh in my path and I threw mommy in there, too. Debug gives me a rendering error 80 with CONFIG ERROR when I try to apply this. Sure it's something silly.

Sorry to reopen, but this was the only discussion here related to oh-my-posh and I didn't think it warranted a new topic (as I'm only referencing a minor part of this one)

@FWDekker
Copy link
Owner

@ziasquinn i don't know much about oh-my-posh, but it seems like that is an error specific to your oh-my-posh configuration. perhaps a typo? i read somewhere that running oh-my-posh debug will show you the exact error message. perhaps that will help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants