所以我尝试为 Windows 安装 oh-my-posh
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
Run Code Online (Sandbox Code Playgroud)
谁能帮我?
首先,我在 oh my posh 中使用 hotstick.minimal 主题。它看起来像这样。
正如您所看到的,当前的 venv 看起来不太好。我对 JSON 文件做了一些更改。然后看起来像这样。
\n\n我不想在左侧显示 venv 的名称。我怎样才能做到这一点?
\n这是我的 JSON 文件:
\n{\n "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",\n "final_space": true,\n "osc99": true,\n "console_title": true,\n "console_title_style": "template",\n "console_title_template": "{{.Folder}}{{if .Root}} :: root{{end}} :: {{.Shell}}",\n "blocks": [\n\n {\n "type": "prompt",\n "alignment": "left",\n "segments": [\n { \n "type": "root",\n "style": "plain",\n "foreground": "yellow",\n "properties": {\n "root_icon": "\xee\x82\xa2"\n }\n },\n {\n "type": "path",\n "style": "powerline",\n "foreground": "black",\n "background": "#68D6D6",\n "powerline_symbol": "\xee\x82\xb0",\n "leading_diamond": "\xee\x82\xb0",\n "trailing_diamond": "\xee\x82\xb0",\n "properties": …Run Code Online (Sandbox Code Playgroud) 我导入 posh-git 但不使用它的提示样式。我的 Windows 终端 $PROFILE 如下:
Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt -Theme default
#$env:POSH_GIT_ENABLED = $true
Run Code Online (Sandbox Code Playgroud)
我读过类似的问题 [ Windows Terminal + oh-my-posh not shown git status并更改了主题文件,但它也不起作用。
主题文件的“git”部分,例如:
Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt -Theme default
#$env:POSH_GIT_ENABLED = $true
Run Code Online (Sandbox Code Playgroud)
所有显示属性(“display_status”...)均为 true。
它不显示 git 状态!为什么?? 图片
我只是想知道 oh-my-posh 是否已弃用 git 状态显示???
我已经阅读了oh-my-posh 博客页面,git 状态显示没有变化
今天我在 PowerShell 中安装了 posh-git,但图标没有显示,而是显示一个内部带有问号的矩形框。以下是我遵循的步骤:
Install-Module oh-my-posh -Scope CurrentUser
然后
Install-Module posh-git -Scope CurrentUser
对于这两个包,我都选择了“Yes To All”选项。
安装软件包后,我打开 Microsoft.PowerShell_profile.ps1文件并添加以下代码片段:
Import-Module oh-my-posh
Import-Module posh-git
Set-PoshPrompt -Theme M365Princess
# M365Princess is the theme name I found from oh-my-posh doc
Run Code Online (Sandbox Code Playgroud)
settings.json之后我在 VS Code 中添加了这个"terminal.integrated.fontFamily": "Fira Code".
仅供参考,我已经安装了该Fira Code Medium Nerd Font Complete Windows Compatible字体。
然后通过VS Code重新启动。颜色显示完美,还有一些图标,但也有一些图标丢失,如下面的屏幕截图中的示例。
请帮我解决这个问题。
我已将 oh-my-posh 配置为在 powershell 上工作,如果我从 Windows 终端运行 powershell,一切都会按预期工作(文档中清楚地说明了这一点)
\n不过,我倾向于从 WSL 终端运行 powershell,因为我有这样的别名\n psl='/mnt/c/Program\\ Files/PowerShell/7/pwsh.exe'
\n但现在当我运行该别名时出现以下错误
\noh-my-posh: C:\\Users\\username\\OneDrive\\Documents\\PowerShell\\Microsoft.PowerShell_profile.ps1:19\nLine |\n 19 | oh-my-posh init pwsh --config 'C:\\Users\\username\\OneDrive\\Documents\\Powe \xe2\x80\xa6\n | ~~~~~~~~~~\n | 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\n | name, or if a path was included, verify that the path is correct and try again\nRun Code Online (Sandbox Code Playgroud)\n有什么想法吗?\n谢谢
\n我尝试更改路径,但终端似乎无法识别 oh-my-posh
\nGet-PSReadLineKeyHandler : A parameter cannot be found that matches parameter name 'Key'.
At line:380 char:43
+ if ((Get-PSReadLineKeyHandler -Key Spacebar).Function -eq ...
+ ~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-PSReadLineKeyHandler], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.GetKeyHandlerCommand
Get-PSReadLineKeyHandler : A parameter cannot be found that matches parameter name 'Key'.
At line:383 char:43
+ if ((Get-PSReadLineKeyHandler -Key Enter).Function -eq 'O ...
+ ~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-PSReadLineKeyHandler], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.GetKeyHandlerCommand
Run Code Online (Sandbox Code Playgroud)
每当我打开 powershell 时都会出现此信息。我可以做什么来解决这个问题?
寻找解决方案。
oh-my-posh ×8
powershell ×6
terminal ×2
windows ×2
posh-git ×1
powerline ×1
psreadline ×1
python ×1
virtualenv ×1
wsl-2 ×1