最近偶然在一個Ruby課程上看到講者電腦用的VIM狀態列與shell命令列相當華麗,一查才知道有powershell系列工具可以讓VIM狀態列更加美觀直覺,powerline原本是針對VIM做美化,也有人改寫可以套用至shell命令列,還直接內建了已經用很習慣的git-prompt,本文主要針對命令列的美化,現在馬上來套用看看!
下載安裝powerline-shell
到powerline-shell專案下載powerline-shell程式碼
https://github.com/milkbikis/powerline-shell/archive/master.zip
解壓縮後進入的powerline-shell資料夾後執行install.py
1 | $ /path/to/powerline/install.py |
修改你的shell設定檔
這邊以bash為例,修改家目錄下的.bash_profile
(或 .bashrc
),其他類型的shell修改方式與更多詳細設定可以自行參考專案網頁中的說明
1 | vim ~/.bash_profile |
修改你的原始prompt內容以掛上powerline-shell
1 | function powerline_shell() { |
安裝字型檔
至powerline-fonts專案下載專用字型包
https://github.com/Lokaltog/powerline-fonts/archive/master.zip
解壓縮後進入資料夾執行install.sh
1 | $ /path/to/powerline-fonts/install.sh |
設定Terminal字型
至terminal設定畫面選擇剛剛裝好的專用字型,名稱特徵是for powerline
結尾
如果找不到就回到powerline-fonts資料夾中個別點選開字型檔案後安裝
重新開啟Shell後大功告成
加上git branch圖示
Git branch名稱部分前面可以加上圖示讓他更醒目直覺,這部份有網友提供修改方式但目前尚未被repo作者採納,有興趣可以自行參考下方連結修改powerline-shell原始碼後重新執行install.py
即可
https://github.com/mohislm/powerline-shell/commit/869b9bc63314315419d2b4072b4b2d3f909dedd5