Merge pull request #888 from ohcibi/feature/add-pathshorten-as-long-branch-name-option

Add `pathshorten` as a built-in format for long branch names
This commit is contained in:
Bailey Ling 2015-12-28 14:56:02 -05:00
commit 2fbdbc8893
2 changed files with 9 additions and 1 deletions

View File

@ -14,6 +14,10 @@ if s:head_format == 1
function! s:format_name(name) function! s:format_name(name)
return fnamemodify(a:name, ':t') return fnamemodify(a:name, ':t')
endfunction endfunction
elseif s:head_format == 2
function! s:format_name(name)
return pathshorten(a:name)
endfunction
elseif type(s:head_format) == type('') elseif type(s:head_format) == type('')
function! s:format_name(name) function! s:format_name(name)
return call(s:head_format, [a:name]) return call(s:head_format, [a:name])

View File

@ -320,9 +320,13 @@ vcscommand <http://www.vim.org/scripts/script.php?script_id=90>
" default value leaves the name unmodifed " default value leaves the name unmodifed
let g:airline#extensions#branch#format = 0 let g:airline#extensions#branch#format = 0
" to only show the tail, e.g. a branch 'feature/foo' show 'foo' " to only show the tail, e.g. a branch 'feature/foo' becomes 'foo', use
let g:airline#extensions#branch#format = 1 let g:airline#extensions#branch#format = 1
" to truncate all path sections but the last one, e.g. a branch
" 'foo/bar/baz' becomes 'f/b/baz', use
let g:airline#extensions#branch#format = 2
" if a string is provided, it should be the name of a function that " if a string is provided, it should be the name of a function that
" takes a string and returns the desired value " takes a string and returns the desired value
let g:airline#extensions#branch#format = 'CustomBranchName' let g:airline#extensions#branch#format = 'CustomBranchName'