So I tried installing oh-my-posh for windows with
所以我试着为Windows安装了oh-my-posh
Install-Module oh-my-posh -Scope CurrentUser
安装模块oh-my-posh -Scope当前用户
and typed
并打字
Get-PoshThemes
Get-Posh主题
to see the available themes which I downloaded.
But I got this message
查看我下载的可用主题。但我收到了这条消息
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
Can anyone help me?
有谁可以帮我?
更多回答
After instaling, shouldn't you also need to Import-Module oh-my-posh
and add that command in your $Profile
?? See this
安装后,您不是还需要导入模块oh-my-posh并将该命令添加到您的$配置文件中吗?看这个
I'm having the same issue... @Theo Import-Module oh-my-posh
didn't fix it for me. It could be an issue with the latest version-- I'm using 6.42.3. When I get a sec, I'll try the latest commit on the oh-my-posh GitHub repo.
我也有同样的问题...@Theo Import-Module噢-my-posh没有为我修复它。这可能是最新版本的问题--我使用的是6.42.3。等我有空的时候,我会尝试一下最新的关于哦我的时髦GitHub回购的提交。
Solution
(Note: I'm running PowerShell 7.1 LTS)
(注:我运行的是PowerShell7.1 LTS)
First, install a Nerd Font:
[skip if you've already done so]
[如果您已经跳过,请跳过]
Instructions for installing a Nerd Font:
安装Nerd字体的说明:
https://learn.microsoft.com/en-us/windows/terminal/tutorials/custom-prompt-setup#install-a-nerd-font
Then, install oh-my-posh
:
1. Install: posh-git
oh-my-posh
:
1.安装:poh-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. ...follow the rest of the instructions here:
2.按照下面的说明操作:
https://github.com/JanDeDobbeleer/oh-my-posh2#installation
3. ...finally, try the command again:
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
Optional
任选
To avoid manually entering Set-PoshPrompt
, include the command in your PowerShell $PROFILE
:
要避免手动输入Set-PoshPrompt,请在PowerShell$配置文件中包含以下命令:
# ...e.g. to use the included 'zash' theme:
Set-PoshPrompt zash
...you should see your PowerShell prompt change when you open a start shell instance (i.e. new PowerShell tab or window).
...当你打开一个启动shell实例(即新的PowerShell选项卡或窗口)时,你应该看到你的PowerShell提示符发生了变化。
Closing thoughts (side-note)
Before I got it to work, I originally followed the instructions here:
在我让它工作之前,我最初是按照下面的说明操作的:
https://learn.microsoft.com/en-us/windows/terminal/tutorials/custom-prompt-setup#install-a-nerd-font
...no mention of the posh-git
module or the Set-PoshPrompt
command (as of 12/30/2021).
...没有提到posh-git模块或set-PoshPrompt命令(截至2021年12月30日)。
I kept getting the cmdlet not found error even after following the guide by Robbie. For some reason a fresh install did not fix it for me but an update did:
我一直收到cmdlet Not Found Error,甚至在遵循Robbie的指导之后也是如此。出于某种原因,新安装没有为我修复它,但更新修复了它:
Update-Module oh-my-posh
I following with docs from ohmyposh and it working with me
我跟着来自ohmyposh的医生,它和我一起工作
Try refreshenv
. It works for me.
试试reshenv吧。这对我很管用。
You can start your vs code by admin permissions and it will be fixed.
I'm using oh-my-posh version 14.29.1
更多回答
Hi, I followed first Microstoft guide than yours (and what is in GitHub) but doesn't work for me. When trying to run Set-Prompt I just get an error: The term 'Set-Prompt' is not recognized as the name of a cmdlet. Any tips how to deal with that?
嗨,我遵循了第一个Microstoft指南,而不是你的指南(以及GitHub中的内容),但对我不起作用。尝试运行Set-Prompt时,我收到一个错误:术语‘Set-Prompt’未被识别为cmdlet的名称。有什么小贴士要怎么处理吗?
@GKroch By Set-Prompt
, do you mean Set-PoshPrompt
? Apologies, I had a typo in one part of my answer (now fixed).
@GKroch by Set-Prompt,你的意思是Set-PoshPrompt吗?抱歉,我的答案中有一部分打错了(现在已经修正了)。
... what exactly from it did you follow? Are you referring to specific part or the whole thing? see also meta.stackexchange.com/a/8259/997587
..。你到底从中学到了什么?你指的是具体的部分还是整个事情?另请参阅meta.stackexchange.com/a/8259/997587
Please provide proper solution to the question
请为这个问题提供适当的解决方案
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
虽然这个链接可能会回答这个问题,但最好在这里包括答案的基本部分,并提供链接以供参考。如果链接的页面发生更改,仅限链接的答案可能会无效。-摘自评论
This is a workaround and not a safe one. If you make a mistake or your profile is compromised, there's signficantly less protection from 'bad things' happening. The oh-my-posh installation instructions work, if you follow them.
这是一个变通办法,而不是一个安全的办法。如果你犯了一个错误,或者你的个人资料被泄露了,那么就不会有太多的保护措施来抵御“坏事”的发生。如果你按照说明去做,安装说明就会起作用。
我是一名优秀的程序员,十分优秀!