diff --git a/autoload/utils.vim b/autoload/utils.vim index 900069c..5bbc7e8 100644 --- a/autoload/utils.vim +++ b/autoload/utils.vim @@ -159,3 +159,12 @@ function! utils#Inside_git_repo() abort return v:true endif endfunction + +function! utils#GetGitBranch() + let l:res = systemlist('git rev-parse --abbrev-ref HEAD')[0] + if match(l:res, 'fatal') != -1 + return '' + else + return l:res + endif +endfunction diff --git a/core/plugins.vim b/core/plugins.vim index 8f901fa..9af4b61 100644 --- a/core/plugins.vim +++ b/core/plugins.vim @@ -421,6 +421,9 @@ let g:airline_symbols.branch = '⎇' let g:airline_symbols.paste = 'ρ' let g:airline_symbols.spell = 'Ꞩ' +" Custom branch name +let g:airline#extensions#branch#custom_head = 'utils#GetGitBranch' + " Only show git hunks which are non-zero let g:airline#extensions#hunks#non_zero_only = 1