oh-my-posh安装
- 官网教程:https://ohmyposh.dev/docs
- 比较全的个人安装文档:https://raimis.me/archives/80/
- 安装流程:
- 安装oh-my-posh
- 配置字体
- 配置主题(默认主题延迟很高,一定要换主题)
1 windows平台
1.1 安装PowerShell和Windows Terminal
- Microsoft Store里搜索PowerShell和Windows Terminal安装即可
1.2 安装oh-my-posh
- 安装windows包管理工具winget:在Microsoft Store里搜索winget安装
- 安装oh-my-posh
winget install JanDeDobbeleer.OhMyPosh -s winget
1.3 配置字体
- 下载字体Meslo LGM NF字体
- 解压后,里面有很多字体,选择其中一个右键安装
- 打开Windows Terminal,打开设置页面,选择pwsh,选择外观栏,在字体栏选择安装的字体
1.4 配置主题(强烈建议)
- Windows Terminal下执行下载主题配置文件包
- 打开$PROFILE文件,没有则创建,如果有vscode,直接
code $PROFILE
打开
echo $PROFILE
d:\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
- 编辑文件配置以下内容:gmay.omp.json是下载的主题配置文件,可任选
oh-my-posh init pwsh --config 'C:\Users\Administrator\AppData\Local\Programs\oh-my-posh\themes\gmay.omp.json' | Invoke-Expression
1.5 vscode配置
- vscode设置默认terminal为pwsh
- 设置terminal字体
- 打开设置菜单,输入
text Font Family
,输入上面安装的字体
2 Linux平台
2.1 下载oh-my-posh
sudo wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-amd64 -O /usr/local/bin/oh-my-posh
sudo chmod +x /usr/local/bin/oh-my-posh
2.2 配置字体
- 如果是在windows上使用ssh工具连接linux,那么只需要在windows上安装字体,然后配置相应的ssh软件即可,具体操作参考windows平台字体安装部分。
2.3 使用oh-my-posh
- 编辑~/.bash_profile文件,插入以下内容(使用默认主题可能会很卡,建议配置主题)
eval "$(oh-my-posh init bash)"
- 执行
exec bash
- 执行
. ~/.profile
2.4 配置主题(强烈建议)
- 下载主题:主题文件存放在
~/.poshthemes/
中
mkdir ~/.poshthemes
wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/themes.zip -O ~/.poshthemes/themes.zip
unzip ~/.poshthemes/themes.zip -d ~/.poshthemes
chmod u+rw ~/.poshthemes/*.omp.*
rm ~/.poshthemes/themes.zip
- 编辑~/.bash_profile文件,插入以下内容,
~/.poshthemes/gmay.omp.json
是主题文件路径,任意选择
eval "$(oh-my-posh init bash --config ~/.poshthemes/gmay.omp.json)"
- 执行
exec bash
- 执行
. ~/.profile