使用 oh-my-posh 优化 Windows Terminal 体验
安装 oh-my-posh
如果有杀毒软件误报毒的情况可以看看下面官方文档怎么解决的。
https://ohmyposh.dev/docs/installation/windows
# 安装 oh-my-posh
winget install JanDeDobbeleer.OhMyPosh -s winget
# 更新 oh-my-posh
winget upgrade JanDeDobbeleer.OhMyPosh -s winget
配置 oh-my-posh
配置字体 fonts
这里我按官方给的推荐字体来安装了。
https://ohmyposh.dev/docs/installation/fonts
oh-my-posh font install meslo
在 Terminal 配置文件里面设置字体,打开 Windows Terminal 的设置,找到 profiles
-> defaults
-> font
-> face
,把它改成下面的字体
{
"profiles": {
"defaults": {
"font": {
"face": "MesloLGM Nerd Font"
}
}
}
}
配置 vscode 的 json 文件,添加字体配置
"terminal.integrated.fontFamily": "MesloLGM Nerd Font"
配置提示 prompt
因为我 WT 用的是 powershell,所以这里只给出了 powershell 的配置,其他的看下面官方文档
https://ohmyposh.dev/docs/installation/prompt
# 使用记事本打开 powershell 的配置文件
# if the profile file does not exist, create it
if (-not (Test-Path $profile)) { New-Item $profile -Force }
# Open the profile file in notepad
notepad $PROFILE
在配置文件内添加一行,让 powershell 每次打开都自动配置 oh-my-posh
oh-my-posh init pwsh | Invoke-Expression
配置主题 themes
可以在这里 看到所有的主题
我喜欢和 Linux / Mac 上保持一致,还是用的 powerlevel10k 的主题,这里安装也需要放到 powershell 的配置文件内,每次都运行
notepad $PROFILE
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/powerlevel10k_rainbow.omp.json" | Invoke-Expression
# 如果安装主题的时候报了下面的错误,可以运行下面的命令
# Get-PSReadLineKeyHandler : A positional parameter cannot be found that accepts argument 'Spacebar'.
Install-Module PsReadLine -Force
# 然后重新打开一遍 Windows Terminal,再装一遍主题
Last updated on