讓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

總結

最終的效果為:

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

感謝

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


免責聲明!

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



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