讓BASH,VIM美美的Powerline

前言

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

Powerline是什麼?

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

安裝Powerline

1.先保證python版本在2.7+python

$ python --version

2.安裝pip,並經過pip安裝powerlinelinux

$ sudo apt install pip
$ pip install powerline-status

安裝/配置字體

 提及樣式怎能少了字體呢?並且Powerline中還用到特殊的字符,須要特定的字體來配合才能達到最佳顯示效果。git

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

而後到Profiles -> Profile Preferences選擇合適的xxx for powerline的字體便可。github

Powerline 4 BASH

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

$ 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》。而後windows

$ 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

總結

最終的效果爲:
bash

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

感謝

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

相關文章
相關標籤/搜索