所以我试着用安装oh my posh for 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
有人能帮我吗?
解决方案
(注意:我正在运行PowerShell 7.1 LTS(
首先,安装Nerd字体:
[如果已经跳过,请跳过]
安装Nerd字体的说明:
https://learn.microsoft.com/en-us/windows/terminal/tutorials/custom-prompt-setup#install-a-nerd-font
然后,安装oh-my-posh
:
1.安装:posh-git
oh-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
。。。未提及CCD_ 8模块或CCD_ 9命令(截至2021年12月30日(。
即使在遵循Robbie的指导之后,我也一直收到cmdlet未找到的错误。出于某种原因,新安装并没有为我修复它,但更新确实修复了:
Update-Module oh-my-posh
我关注ohmyposh的文档,它与我一起工作
尝试refreshenv
。它对我有用。
您可以通过管理员权限启动vs代码,它将被修复。我正在使用哦我的豪华版本14.29.1