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