Skip to content

Instantly share code, notes, and snippets.

View bla-rs's full-sized avatar

bla-rs

  • Germany
View GitHub Profile
@bla-rs
bla-rs / gist:c439daa0aaa5dea899056bc0b7d34ead
Last active December 19, 2020 01:43 — forked from rgs/gist:7370406
A vim status line item to display git branch name and status of the currently edited file. To be put in the ~/.vimrc.
" returns a string <branch/XX> where XX corresponds to the git status
" (for example "<master/ M>")
function! CurrentGitStatus()
let gitoutput = systemlist('cd '.expand('%:p:h:S').' && git status --porcelain -b 2>/dev/null')
if len(gitoutput) > 0
let b:gitstatus = strpart(get(gitoutput,0,''),3) .'/'. strpart(get(gitoutput,1,' '),1,2)
else
let b:gitstatus = ''
endif
endfunc