术语“oh-my-posh”不被识别为命令的名称。

3

我已经配置好了 oh-my-posh 在 powershell 上的运行,如果我从 Windows 终端中运行 powershell(这正如文档明确说明的那样),则一切都按预期工作。

然而,我倾向于从我的 WSL 终端中运行 powershell,因为我有这样一个别名:

psl='/mnt/c/Program\ Files/PowerShell/7/pwsh.exe'

但是现在当我运行该别名时,我得到了以下错误:

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

有什么想法吗? 谢谢

我试图改变路径,但终端好像无法识别oh-my-posh。


你的 WSL 用户是否可以看到/使用 oh-my-posh? - Vish
我该如何检查呢?我基本上是通过别名从wsl转到PowerShell。 - Oggy
检查 $env:PATH - Subjective Reality
1个回答

1
在Windows上,使用Get-Command oh-my-posh验证可执行文件的位置,并在启动PowerShell时将其添加到PATH中,最好是通过将其添加到$PROFILE来实现。
$env:Path += ";/mnt/c/Program\ Files/exact/location/oh-my-posh.exe"

话虽如此,不建议在WSL上使用Windows版本的oh-my-posh,因为它比本地Linux构建要慢。PowerShell的Windows版本也是如此。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接