Skip to content

Instantly share code, notes, and snippets.

@smeghead
Created April 25, 2011 02:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smeghead/940094 to your computer and use it in GitHub Desktop.
Save smeghead/940094 to your computer and use it in GitHub Desktop.
display git branch on statusline.
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