介绍在PowerShell Core中安装oh-my-posh和配置Cascadia字体及自定义快捷键的过程。

Windows oh-my-posh 配置
1 mins
92 words
Loading views

环境h2

安装 oh-my-poshh2

官方文档:https://ohmyposh.dev/docs/installation/windows

Terminal window
iwr https://ohmyposh.dev/install.ps1 -useb | iex

安装 Cascadia 字体h2

下载地址:https://www.programmingfonts.org/#cascadia-code

选择一个安装即可,本例选用 CaskaydiaCoveNerdFont-Light.ttf

配置文件h2

编辑 PowerShell 配置文件:

Terminal window
code $PROFILE

添加以下内容并保存:

Terminal window
oh-my-posh init pwsh --config C:\Users\admin\App\poweshell.omp.json | Invoke-Expression
Set-PSReadLineKeyHandler -Key Ctrl+d -ScriptBlock {
[Microsoft.PowerShell.PSConsoleReadLine]::RevertLine()
[Microsoft.PowerShell.PSConsoleReadLine]::Insert('exit')
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
}
Set-Alias ll ls
Set-Alias open ii
Set-Alias type Get-Command
Set-Alias wind windsurf.cmd