FWDekker / mommy

mommy's here to support you, in any shell, on any system~ ❤️
The Unlicense
197 stars 5 forks source link

🪟 powershell support #124

Closed Satanarious closed 5 months ago

Satanarious commented 5 months ago

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 commented 5 months ago

please mommy support powershell~

Delusoire commented 5 months ago

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

FWDekker commented 5 months ago

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 :-)

Satanarious commented 5 months ago

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

FWDekker commented 5 months ago

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 commented 5 months ago
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 commented 5 months ago

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 commented 5 months ago
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 commented 5 months ago
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 commented 5 months ago

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 commented 5 months ago

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

ziasquinn commented 2 months ago

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 commented 2 months ago

@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?