windows 尝试安装oh-my-posh,但它告诉我“该术语不被识别为...”

uujelgoq  于 2023-04-13  发布在  Windows
关注(0)|答案(3)|浏览(460)

所以我试着在windows上安装了
Install-Module oh-my-posh -Scope CurrentUser
然后打字
Get-PoshThemes
看到我下载的可用主题。但我得到了这个消息

Get-PoshThemes : The term 'Get-PoshThemes' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:1
+ Get-PoshThemes
+ ~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-PoshThemes:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

谁能帮帮我?

nnsrf1az

nnsrf1az1#

溶液

  • (注意:我正在运行PowerShell 7.1 LTS)*

首先安装一个Nerd Font:

  • [如果你已经跳过]*
    Nerd字体安装说明:

https://learn.microsoft.com/en-us/windows/terminal/tutorials/custom-prompt-setup#install-a-nerd-font

然后安装oh-my-posh

1.安装:posh-gitoh-my-posh

# This first step isn't included in the Microsoft Docs page:
   Install-Module posh-git -Scope CurrentUser
   
   # ...though this one is:
   Install-Module oh-my-posh -Scope CurrentUser

2. ...按照此处的其余说明操作:

https://github.com/JanDeDobbeleer/oh-my-posh2#installation

3. ...最后再试一次命令:

# Set the prompt theme (defaults to 'agnoster' for me)
   # ! Note: You have to do this step first (or it still won't work)
   Set-PoshPrompt

   # List the available themes (should work now)
   # ! Note: this will attempt to render a bunch of graphics in your shell
   Get-PoshThemes
   
   # ! Note: use the -List option to avoid a bunch of graphics in your shell
   # This will list the paths to the themes (in plaintext):
   Get-PoshThemes -List

可选

要避免手动输入Set-PoshPrompt,请在PowerShell $PROFILE中包含以下命令:

# ...e.g. to use the included 'zash' theme:
    Set-PoshPrompt zash

...当你打开一个启动shell示例(即新的PowerShell选项卡或窗口)时,你应该看到你的PowerShell提示符发生了变化。

结束语(旁注)

在我让它工作之前,我最初是按照这里的指示:
https://learn.microsoft.com/en-us/windows/terminal/tutorials/custom-prompt-setup#install-a-nerd-font
...没有提到posh-git模块或Set-PoshPrompt命令(截至2021年12月30日)。

kse8i1jr

kse8i1jr2#

我一直得到cmdlet找不到错误,即使在遵循Robbie的指南后。由于某种原因,全新安装没有为我修复它,但更新做到了:

Update-Module oh-my-posh
e0bqpujr

e0bqpujr3#

你可以通过管理员权限启动你的vs代码,它会被修复的。我用的是oh-my-posh版本14.29.1

相关问题