一,安装 Nerd Font 字体#
避免出现字符 “▯”,Nerd Font 字体下载地址https://www.nerdfonts.com/font-downloads
二,安装适用于 PowerShell 的 Oh My Posh#
1. 使用 winget 安装#
winget install oh-my-posh
2. 使用 Microsoft Store 安装#
3. 选择并应用 PowerShell 主题#
notepad $PROFILE
填写内容#
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\paradox.omp.json" | Invoke-Expression
主题官网:https://ohmyposh.dev/docs/themes
三,可能的问题#
1.notepad $PROFILE 可能会提示系统找不到指定的路径,参考 Microsoft 文档https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7.3 中的 Profile types and locations 部分自行创建,然后重启 Windows Terminal 即可。
#
2. 无法加载文件 ***\WindowsPowerShell\profile.ps1, 因为在此系统上禁止运行脚本#
查看现用执行策略
>> get-executionpolicy
Restricted
更改执行策略,以管理员身份打开 PowerShell
>> set-executionpolicy remotesigned
选择 a 或者 y 选项,再次重启 Windows Terminal。