推荐好玩的工具之OhMyPosh使用

143 阅读1分钟
  1. 解除禁止脚本

    Set-ExecutionPolicy RemoteSigned

  2. 下载Oh My Posh

    winget install oh-my-posh

    或者

    Install-Module oh-my-posh -Scope AllUsers

  3. 下载Git提示

    Install-Module posh-git -Scope CurrentUser

    或者

    Install-Module posh-git -Scope AllUser

  4. 下载命令提示

    Install-Module PSReadLine -RequiredVersion 2.1.0

  5. 添加配置

    notepad $profile

    添加以下配置

    Import-Module PSReadLine
    Set-PSReadLineOption -PredictionSource History
    Set-PSReadLineKeyHandler -Chord "Ctrl+RightArrow" -Function ForwardWord
    Import-Module posh-git
    oh-my-posh init pwsh --config D:\ProgramData\PowerShellTheme\onehalf.minimal.omp.json | Invoke-Expression
    

    注意: D:\ProgramData\PowerShellTheme\onehalf.minimal.omp.json为添加主题JSON文件本地路劲(主题列表:Themes | Oh My Posh),可以在主题列表里面选择自己喜欢的

  6. 添加font,(可选,这是设置自己字体类型)

  7. 设置font

  8. oh-my-posh报错重启电脑(注意C盘用户名为中文

  9. 配置流程出现问题

    可能原因:oh-my-posh不再维护windows shell版本,官网:ohmyposh.dev/docs/

    Installation→Windows→manual,复制指令进终端:

    Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://ohmyposh.dev/install.ps1'))
    
    

本人选的主题

1720276196166.jpg