Windows Terminal美化CMD和PowerShell
一、oh my posh安装配置
1、下载安装
官网:https://ohmyposh.dev/docs/installation/windows
winget install JanDeDobbeleer.OhMyPosh -s winget #安装
winget upgrade JanDeDobbeleer.OhMyPosh -s winget #更新
2、环境配置
检查环境变量是否存在如下变量:
成功标志:
3、字体安装
oh-my-posh font install #选择要安装字体,因为要用GitHub,建议离线下载安装,资源见资源汇总
#将压缩包解压,tff文件全复制到Windows的Fonts中自动安装,然后在WindowsTerminal中选择安装的字体则可,默认字体可能会出现乱码
二、CMD美化
1、Clink安装
2、新增配置文件
oh-my-posh.lua #文件名,创建在Clink的安装目录下
load(io.popen('oh-my-posh init cmd'):read("*a"))() #默认主题
load(io.popen('oh-my-posh init cmd --config C:/Users/username/AppData/Local/Programs/oh-my-posh/themes/kali.omp.json'):read("*a"))() #自定义主体,然后重启CMD就可以了,记得改用户名
三、PowerShell美化
#安装完OhMyPosh后PowerShell需要重启执行下面命令
New-Item -Path $PROFILE -Type File -Force #输入$PROFILE后没有WindowsPowerShell\Microsoft.PowerShell_profile.ps1文件,则用这个命令创建,默认没有需要新建
notepad $PROFILE #编辑新建的Microsoft.PowerShell_profile.ps1文件
oh-my-posh init pwsh | Invoke-Expression #添加启动项配置,默认配置此处以kali主体为示例,其他可在官网查看效果
oh-my-posh init pwsh --config C:/Users/username/AppData/Local/Programs/oh-my-posh/themes/kali.omp.json | Invoke-Expression #记得改username
. $PROFILE #配置生效
四、资源汇总
链接:https://pan.baidu.com/s/1eYVoprTPZxNciWFbjvQusg?pwd=what
提取码:what