安装oh-my-posh, gsudo
winget install JanDeDobbeleer.OhMyPosh
winget install gsudo
打开window terminal,配置
给window terminal添加管理员权限,前面添加gsudo,后面添加 -NoLogo
在终端输入以下指令,打开配置文件,配置oh-my-posh
notepad.exe $profile
将以下输入保存关闭
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\montys.omp.json" | Invoke-Expression
Set-PSReadLineOption -PredictionSource History # 设置预测文本来源为历史记录
Set-PSReadlineKeyHandler -Key Tab -Function Complete # 设置 Tab 键补全
Set-PSReadLineKeyHandler -Key "Ctrl+d" -Function MenuComplete # 设置 Ctrl+d 为菜单补全和 Intellisense
Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo # 设置 Ctrl+z 为撤销
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward # 设置向上键为后向搜索历史记录
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward # 设置向下键为前向搜索历史纪录
到这个网站下载字体:www.nerdfonts.com/font-downlo…
找到mononoki Nerd Font,下载安装。
安装输入提示扩展包
Install-Module posh-git -Scope CurrentUser
Install-Module -Name PSReadLine -Scope CurrentUser -Force -SkipPublisherCheck
重启电脑即可看到效果
输入提示的操作,如果想要清除历史,可以输入以下指令
Remove-Item (Get-PSReadlineOption).HistorySavePath
如果想要手动清除某个隐私历史,可在以下位置编辑记录
C:\Users\DGBUAA\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine
但是修改了之后,会改变系统的环境变量,需要再配置环境变量。
%SystemRoot%\system32
%SystemRoot%
%SystemRoot%\System32\Wbem
参考文章: