logo头像
Snippet 博客主题

oh-my-posh配置手册

本文于 852 天之前发表,文中内容可能已经过时。

  1. 安装oh-my-posh

    1
    winget install JanDeDobbeleer.OhMyPosh -s winget
  2. 配置

    1
    code $PROFILE
    • 按需求配置 PROFILE
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    #根据爱好设置主题名(exp:robbyrussell)
    oh-my-posh init pwsh --config $env:POSH_THEMES_PATH\robbyrussell.omp.json | Invoke-Expression

    Import-Module posh-git # 引入 posh-git ➜ ~ Install-Module -Name posh-git -Scope CurrentUser
    Import-Module PSReadLine # 历史命令联想

    # 设置预测文本来源为历史记录
    Set-PSReadLineOption -PredictionSource History
    # 设置 Tab 为菜单补全和 Intellisense
    #Set-PSReadLineKeyHandler -Key "Tab" -Function MenuComplete
    # 每次回溯输入历史,光标定位于输入内容末尾
    #Set-PSReadLineOption -HistorySearchCursorMovesToEnd
    # 设置向上键为后向搜索历史记录
    #Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
    # 设置向下键为前向搜索历史纪录
    #Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
    Set-PSReadLineOption -PredictionViewStyle ListView
  3. 美化

  4. 问题汇总

    • Get-PSReadLineKeyHandler : 找不到与参数名称“Key”匹配的参数。
      1
      2
      3
      4
      #安装预览版PSReadLine
      Install-Module -Name PowerShellGet -Force
      #安装预览版PSReadLine
      Install-Module PSReadLine -AllowPrerelease -Force