1、下载字体
Nerd Fonts - Iconic font aggregator, glyphs/icons collection, & fonts patcher
注:后面设置字体font: CaskaydiaMono Nerd Font
2、安装字体
3、安装 oh-my-posh
oh-my-posh文档地址:https://ohmyposh.dev/docs/windows
在终端中安装oh-my-posh:
winget install JanDeDobbeleer.OhMyPosh
升级:winget upgrade JanDeDobbeleer.OhMyPosh
4、主题配置
将下载的主题放入
~\AppData\Local\Programs\oh-my-posh\themes\目录即可。
oh-my-posh/themes at main · JanDeDobbeleer/oh-my-posh · GitHub
5、设置字体
6、设置主题
1.更改PowerShell安全策略
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
2.打开配置文件notepad $PROFILE
如果配置文件不存在,会提示创建新文件,或者以PowerShell命令创建:
New-Item -Path $PROFILE -Type File -Force
3.写入命令
oh-my-posh init pwsh | Invoke-Expression
4.重新加载配置
. $PROFILE
5.查看可用主题
Get-PoshThemes
6.打开末尾图片路径,将完整主题名配置上。
notepad $PROFILE
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/主题名" | Invoke-Expression
. $PROFILE
7.其他
增强:PSReadLine、oh-my-posh、posh-git,包括语法高亮、错误提示等。