Created
April 25, 2011 02:54
-
-
Save smeghead/940094 to your computer and use it in GitHub Desktop.
display git branch on statusline.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
autocmd WinEnter,BufEnter * let b:__gitbranchname = system('cd ' . expand('%:p:h') . ' && git symbolic-ref HEAD 2> /dev/null') | |
"文字コード改行コードの取得 | |
function! GetStatusEx() | |
let str = '' | |
let str = str . '[\n:' . &fileformat . ']' | |
if has('multi_byte') && &fileencoding != '' | |
let str = str . '[enc:' . &fileencoding . ']' | |
else | |
let str = str . '[enc:default(cp932)]' | |
endif | |
if b:__gitbranchname != '' | |
let str = str . '[git:' . substitute(b:__gitbranchname, '\n', '', '') . ']' | |
endif | |
return str | |
endfunction | |
"ステータスバーの表示 | |
set statusline=%<%f%h%m%r\ %{GetStatusEx()}%=%b\ 0x%B\ \ \ %l,%c%V\ %P |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment