效果图 有提示

window 自定义终端(自动补全powershell 7 + oh-my-posh)

win11装置

powershell 7 下载msi文件 装置的时候需求都勾选上

github.com/PowerShell/…

下载并装置 CaskaydiaCove NF Mono window regluar 字体

www.nerdfonts.com/font-downlo…

翻开powershell 输入下面的指令,网络欠好的的话,需求‘科学上网’。

$env:SCOOP='D:\scoop'
irm get.scoop.sh -outfile 'install.ps1'
iex "& {$(irm get.scoop.sh)} -RunAsAdmin"
scoop install https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/oh-my-posh.json

装置 posh-git

github.com/dahlbyk/pos…

PowerShellGet\Install-Module posh-git -Scope CurrentUser -Force

输入指令 code $PROFILE 仿制下面内容,vscode主动翻开装备文件,保存下面内容

主题可选: ohmyposh.dev/docs/themes

# 设置以运用 @antfu/ni,https://github.com/antfu/ni
Remove-Item Alias:ni -Force -ErrorAction Ignore
Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete #Tab键会呈现主动补全菜单
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
# 上下方向键箭头,查找历史中进行主动补全
# 设置主题,主题丰富。https://ohmyposh.dev/docs/themes
# oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/jandedobbeleer.omp.json" | Invoke-Expression
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/amro.omp.json" | Invoke-Expression
# Import-Module oh-my-posh
Import-Module posh-git # git的主动补全

vscode 装备

{
  "terminal.integrated.profiles.windows": {
    "PowerShell 7": {
      "path": "C:\Program Files\PowerShell\7\pwsh.exe",
      "args": []
    }
  },
  // 有可能是PowerShell,不对会有报错下划线
  "terminal.integrated.defaultProfile.windows": "PowerShell 7",
  "terminal.integrated.fontFamily": "CaskaydiaCove NF Mono"
}

win11的终端设置里面json

{
  list: [
    {
      "commandline": "C:\Program Files\PowerShell\7\pwsh.exe",
      "guid": "{be8c6241-aafb-437f-8d7c-a7142adf7f54}",
      "hidden": false,
      "icon": "C:\Program Files\PowerShell\7\assets\ps_black_32x32.ico",
      "name": "PowerShell Core"
    }
  ]
}

win10 还需求装备

翻开

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Windows PowerShell

window 自定义终端(自动补全powershell 7 + oh-my-posh)

把目标换成powershell 7的pwsh.exe的途径,我的途径是 C:\Program Files\PowerShell\7\pwsh.exe ,此时再开始菜单右键唤起powershell 就是 7版别的了,

在文件夹里面唤起可以直接在文件途径处输入pwsh,在win+r 的输入框也可以直接运用pwsh