Try   HackMD

Powerline: 終端機界面小工具

簡介

Powerline 是一個終端機的外掛小工具,支援各種常見的 Shell 與 Vim,可以讓命令提示字元與 Vim 的狀態列更美觀易讀。

安裝

  1. Ubuntu 14.04 之後的版本,可以直接使用以下指令安裝
    ​​​​sudo apt-get install powerline
    
  2. 下載 Powerline 字型與 fontconfig 字型設定檔
    ​​​​wget https://github.com/powerline/powerline/raw/develop/font/PowerlineSymbols.otf
    ​​​​wget https://github.com/powerline/powerline/raw/develop/font/10-powerline-symbols.conf
    
  3. 將 PowerlineSymbols.otf 字型放入字型目錄
    ​​​​mv PowerlineSymbols.otf ~/.fonts/
    
  4. 更新字型快取
    ​​​​fc-cache -vf ~/.fonts/
    
  5. 將字型設定檔放進適當的目錄
    ​​​​mv 10-powerline-symbols.conf ~/.config/fontconfig/conf.d/
    

設定

Bash Shell

  1. ~/.bashrc 中加入下列程式碼

    ​​​​POWERLINE_SCRIPT=/usr/share/powerline/bindings/bash/powerline.sh
    ​​​​if [ -f $POWERLINE_SCRIPT ]; then
    ​​​​source $POWERLINE_SCRIPT
    ​​​​fi
    
  2. 修改設定,以顯示 git branch

    1. 開啟 ~/.config/powerline/config.json
    2. shell 內的 theme 的設定值由 default 改為 default_leftonly
      ​​​​​​​​"shell": {
      ​​​​​​​​"colorscheme": "default",
      ​​​​​​​​"theme": "default_leftonly",
      ​​​​​​​​"local_themes": {
      ​​​​​​​​"continuation": "continuation",
      ​​​​​​​​"select": "select"
      
  3. 重新開啟終端機,即可看到 Powerline 的效果

Vim

~/.vimrc 中加入下列設定

set laststatus=2
set t_Co=256

參考資料