本文最后更新于:1 年前
oh-my-posh安装教程
简介
docs中有详细的安装和使用说明,下文中有不明白的可以移步官方文档自行学习使用~
安装
下面以新安装的x86_64的debian环境进行举例
Linux debian 5.10.0-19-amd64 #1 SMP Debian 5.10.149-2 (2022-10-21) x86_64 GNU/Linux
针对内网和非root用户进行安装,避免污染其他用户的使用环境
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| #!/bin/bash
mkdir -p ~/oh-my-posh wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-amd64 -O ~/oh-my-posh/posh; wait; chmod +x ~/oh-my-posh/posh;
mkdir -p ~/oh-my-posh/.poshthemes; wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/themes.zip -O ~/oh-my-posh/.poshthemes/themes.zip; wait; unzip -q ~/oh-my-posh/.poshthemes/themes.zip -d ~/oh-my-posh/.poshthemes; wait; rm ~/oh-my-posh/.poshthemes/themes.zip -vf; chmod u+rw ~/oh-my-posh/.poshthemes/*.omp.*;
sed -i '$a eval "$(~/oh-my-posh/posh init bash --config ~/oh-my-posh/.poshthemes/montys.omp.json)"' ~/.profile;
source ~/.profile;
|
示例动画
montys.omp.json主题微调
由于montys主题默认会在powerline中输出完整的路径,当路径层级较深时,powerline显示就太长了,因此参考文档进行了微调。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
@@ -17,10 +17,11 @@ "foreground": "#ffffff", "powerline_symbol": "\ue0b0", "properties": { - "folder_icon": "\uf115", + "folder_icon": "\uf07c", "folder_separator_icon": "\\", "home_icon": "\uf7db", - "style": "full" + "style": "agnoster_short", + "max_depth": 3 }, "style": "powerline", "template": " <#000>\uf07b \uf553</> {{ .Path }} ",
|
效果对比:
before:
after: