Added the git branch in the statusline

This commit is contained in:
Marcin Woźniak 2021-11-16 16:53:03 +01:00
parent 0ec5de785c
commit 0338073f9d

View File

@ -162,6 +162,15 @@ highlight ColorColumn ctermbg=236
""""""""""""""""""""""""""""""""
" Status Line
""""""""""""""""""""""""""""""""
function! GitBranch()
return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'")
endfunction
function! StatuslineGit()
let l:branchname = GitBranch()
return strlen(l:branchname) > 0?' '.l:branchname.' ':''
endfunction
set statusline=
set statusline+=%#IncSearch#
set statusline+=\ %y
@ -170,6 +179,7 @@ set statusline+=\ %r
set statusline+=%#CursorLineNr#
set statusline+=\ %F
set statusline+=%= "Right side settings
set statusline+=%{StatuslineGit()}
set statusline+=%#Search#
set statusline+=\ %l/%L
set statusline+=\ [%c]