閱讀888 返回首頁    go 阿裏雲 go 技術社區[雲棲]


讓BASH,VIM美美的Powerline

前言

 鑒於BASH及其周邊強大的工具以及VIM高效快捷,加上現在我工作重心轉移到前端開發上,因此我華麗地轉向Linux陣營(當然從最傻瓜式的Ubuntu開始啦!)。但BASH和VIM默認樣式確實顏值太低,功能強大固然重要,但在這看臉的時代誰不愛美呢?那麼我們先拿狀態欄來開刀吧,而刀就是強大酷炫的Powerline本尊了。

Powerline是什麼?

 Powerline是個stateless status line,即可以配置到BASH,ZSH,VIM等上,而不像vim-powerline那樣僅能用於vim.

安裝Powerline

1.先保證python版本在2.7+

$ python --version

2.安裝pip,並通過pip安裝powerline

$ sudo apt install pip
$ pip install powerline-status

安裝/配置字體

 說起樣式怎能少了字體呢?而且Powerline中還用到特殊的字符,需要特定的字體來配合才能達到最佳顯示效果。

$ git clone https://github.com/powerline/fonts &&
./fonts/install.sh

然後到Profiles -> Profile Preferences選擇合適的xxx for powerline的字體即可。

Powerline 4 BASH

 安裝好powerline後,就是配置.bashrc了。

$ cat >> .bashrc << EOF
source $(pip show powerline-status | awk '/Location:/{print $2 "/powerline/bindings/bash/powerline.sh"}')
EOF

Powerline 4 VIM

 相對BASH,將Powerline配置到VIM會複雜一些。首先要準備一個支持Python2的VIM,具體操作請參考《讓VIM支持Python2 by update-alternatives》。然後

$ cat >> .vimrc << EOF
set rtp+=$(pip show powerline-status | awk '/Location:/{print $2 "/powerline/bindings/vim"}')

" These lines setup the environment to show graphics and colors correctly.
set nocompatible
set t_Co=256

let g:minBufExplForceSyntaxEnable = 1
python from powerline.vim import setup as powerline_setup
python powerline_setup()
python del powerline_setup

if ! has('gui_running')
   set ttimeoutlen=10
   augroup FastEscape
      autocmd!
      au InsertEnter * set timeoutlen=0
      au InsertLeave * set timeoutlen=1000
   augroup END
endif

set laststatus=2 " Always display the statusline in all windows
set guifont=Inconsolata\ for\ Powerline:h14
set noshowmode " Hide the default mode text (e.g. -- INSERT -- below the statusline)
EOF

總結

最終的效果為:

 尊重原創,轉載請注明來自:https://www.cnblogs.com/fsjohnhuang/p/6057013.html^_^肥仔John

感謝

為Bash和VIM配置一個美觀奢華的狀態提示欄

最後更新:2017-05-05 11:31:40

  上一篇:go 讓VIM支持Python2 by update-alternatives
  下一篇:go 網絡爬蟲之網頁排重:語義指紋