Windows Terminal 美化
下载安装 winget
可以从 Microsoft Store 下载,也可以从 Github 下载。
winget 安装 Oh My Posh
在 windows terminal 中 键入以下命令:
winget install JanDeDobbeleer.OhMyPosh
winget 自动将 Oh My Posh 安装到 ~\AppData\Local\Programs\oh-my-posh
(~
表示用户根目录,例如我的目录是 C:\Users\DenyC\AppData\Local\Programs\oh-my-posh),并自动将~\AppData\Local\Programs\oh-my-posh\bin
添加到了用户环境变量 path(建议自己手动添加到系统环境变量 path)。
美化字体的添加
首先要添加合适的字体才不会在终端美化后出现乱码的问题
方式1
:管理员身份启动终端,执行命令(受限于网络,不推荐)
oh-my-posh font install
方式2
:官网下载合适的字体再安装(推荐)
字体:https://www.nerdfonts.com/font-downloads
下载后选择喜欢的字体安装即可
PowerShell 的美化
在~\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
文件中添加以下内容:
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\atomic.omp.json" | Invoke-Expression
其中atomic.omp.json
可以换成~\AppData\Local\Programs\oh-my-posh\themes
目录下,自己喜欢的主题(不知道哪个好看?)
输入get-Poshthemes
命令:
get-Poshthemes
Git Bash 的美化
在~
目录下新建.bashrc
文件并添加以下内容:
eval "$(oh-my-posh --init --shell bash --config ~/AppData/Local/Programs/oh-my-posh/themes/atomic.omp.json)"
其中atomic.omp.json
可以换成~\AppData\Local\Programs\oh-my-posh\themes
目录下,自己喜欢的主题。
之后在终端设置选项中更改字体为已下载安装好的字体
Windows CMD 的美化
-
下载 Lua 文件:https://luabinaries.sourceforge.net/download.html
之后在C:\Program Files\
文件夹下新建lua
文件夹,并将下载的文件夹里的lua54.exe
拷贝到lua
文件夹下。
-
下载 Clink clink_setup.exe:https://github.com/chrisant996/clink/releases,并安装。
-
在
~\AppData\Local\clink
文件夹下创建cmd-oh-my-posh.lua
文件,并写入以下内容:local custom_prompt = clink.promptfilter(50) function custom_prompt:filter(prompt) load(io.popen('oh-my-posh init cmd --config ~/AppData/Local/Programs/oh-my-posh/themes/atomic.omp.json'):read("*a"))() end
-
重启 Windows Terminal 使之生效