The term 'oh-my-posh' is not recognized as a name of a cmdlet

3.1k Views Asked by At

I have configured oh-my-posh to be working on powershell and all is working as expected if I run powershell from windows terminal (which is what the document say clearly)

However I tend to run powershell from my WSL terminal as I have alias like this psl='/mnt/c/Program\ Files/PowerShell/7/pwsh.exe'

but now when I run that alias I got the following error

oh-my-posh: C:\Users\username\OneDrive\Documents\PowerShell\Microsoft.PowerShell_profile.ps1:19
Line |
  19 |  oh-my-posh init pwsh --config 'C:\Users\username\OneDrive\Documents\Powe …
     |  ~~~~~~~~~~
     | The term 'oh-my-posh' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the
     | name, or if a path was included, verify that the path is correct and try again

Any idea ? Thanks

I tried to change the path but it seems the terminal is not recognize the oh-my-posh

1

There are 1 best solutions below

0
On

On Windows, validate the location of the executable using Get-Command oh-my-posh and add that to the PATH when starting PowerShell, preferably by adding that to your $PROFILE.

$env:Path += ";/mnt/c/Program\ Files/exact/location/oh-my-posh.exe"

That said, it's discouraged to use the Windows version of oh-my-posh on WSL as that will be slower than a native linux build. Same goes for the Windows version of PowerShell.