效果图 有提示
win11安装
powershell 7 下载msi文件 安装的时候需要都勾选上
下载并安装 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
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.external.windowsExec": "C:\\Program Files\\PowerShell\\7\\pwsh.exe"
"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
把目标换成powershell 7的pwsh.exe的路径,我的路径是 C:\Program Files\PowerShell\7\pwsh.exe ,此时再开始菜单右键唤起powershell 就是 7版本的了,
在文件夹里面唤起可以直接在文件路径处输入pwsh,在win+r 的输入框也可以直接使用pwsh。