ubuntu 安裝 oh-my-posh


前言

根據 Windows Terminal 中 powerline 的教程發現 oh-my-posh 還可以安裝到 ubuntu 系統下,於是嘗試了一下

安裝

Windows Terminal 中 ubuntu 安裝 oh-my-posh 教程:https://docs.microsoft.com/en-us/windows/terminal/tutorials/powerline-setup

oh-my-posh 官網:https://ohmyposh.dev/docs/

安裝 oh-my-posh

wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-amd64 -O /usr/local/bin/oh-my-posh
chmod +x /usr/local/bin/oh-my-posh

配置

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/*.json
rm ~/.poshthemes/themes.zip

如果您使用的是 Ubuntu 18.04 或 16.04,則需要先安裝正確版本的 golang:

sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt update

自定義您的 Ubuntu 提示

查看所有主題

for file in ~/.poshthemes/*.omp.json; do echo "$file\n"; oh-my-posh --config $file --shell universal; echo "\n"; done;

~/.bashrc使用nano ~/.bashrc或您選擇的文本編輯器打開文件。這是一個 bash 腳本,每次 bash 啟動時運行。添加以下內容(將主題更改為您喜歡的主題):

eval "$(oh-my-posh --init --shell bash --config ~/.poshthemes/jandedobbeleer.omp.json)"

如果出現亂碼注意安裝字體 官方推薦字體 Cascadia Mono PL 使用上會有問題 ,推薦 Meslo LGM NF

字體安裝

官方推薦Meslo LGM NFhttps://ohmyposh.dev/docs/fonts

下載地址:https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/Meslo.zip

安裝方法:https://www.cnblogs.com/yuqianwen/p/3715835.html

解壓

unzip Meslo.zip -d Meslo
cd Meslo

安裝

 sudo mkdir /usr/share/fonts/ttf
 sudo cp *.ttf /usr/share/fonts/ttf
 cd /usr/share/fonts/ttf
 sudo chmod 744 *
 sudo mkfontscale
 sudo mkfontdir
 sudo fc-cache -f -v

image-01

在 vscode 中字體設置

"terminal.integrated.fontFamily": "MesloLGM NF"


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM