【问题标题】:Tried to install oh-my-posh but it tells me that "the term is not recognized as..."试图安装 oh-my-posh 但它告诉我“该术语未被识别为......”
【发布时间】:2022-01-16 22:45:32
【问题描述】:

所以我尝试安装 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

谁能帮帮我?

【问题讨论】:

  • 安装后,您是否还需要Import-Module oh-my-posh 并将该命令添加到您的$Profile 中?见this
  • 我遇到了同样的问题...@Theo Import-Module oh-my-posh 没有为我解决这个问题。这可能是最新版本的问题——我使用的是 6.42.3。当我得到一秒钟的时间,我会在 oh-my-posh GitHub repo 上尝试最新的提交。

标签: windows powershell oh-my-posh


【解决方案1】:

解决方案

(注意:我运行的是 PowerShell 7.1 LTS)

首先,安装 Nerd 字体:

[如果你已经这样做了,请跳过]

Nerd 字体安装说明:

https://docs.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://docs.microsoft.com/en-us/windows/terminal/tutorials/custom-prompt-setup#install-a-nerd-font

...没有提及 posh-git 模块或 Set-Prompt 命令(截至 2021 年 12 月 30 日)。

【讨论】:

    猜你喜欢
    • 2023-03-18
    • 2021-05-09
    • 2023-02-23
    • 1970-01-01
    • 2022-12-20
    • 2015-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多