From b48e2390cbfad9a46e2c78c7214713fc3b3290ab Mon Sep 17 00:00:00 2001 From: Tobias Witt Date: Thu, 19 Nov 2015 11:03:54 +0100 Subject: [PATCH] Add `pathshorten` as a built-in format for long branch names --- autoload/airline/extensions/branch.vim | 4 ++++ doc/airline.txt | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/autoload/airline/extensions/branch.vim b/autoload/airline/extensions/branch.vim index 7ad4650..01e2320 100644 --- a/autoload/airline/extensions/branch.vim +++ b/autoload/airline/extensions/branch.vim @@ -14,6 +14,10 @@ if s:head_format == 1 function! s:format_name(name) return fnamemodify(a:name, ':t') endfunction +elseif s:head_format == 2 + function! s:format_name(name) + return pathshorten(a:name) + endfunction elseif type(s:head_format) == type('') function! s:format_name(name) return call(s:head_format, [a:name]) diff --git a/doc/airline.txt b/doc/airline.txt index 9b5f00f..7911a69 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -320,9 +320,13 @@ vcscommand " default value leaves the name unmodifed 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 + " 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 " takes a string and returns the desired value let g:airline#extensions#branch#format = 'CustomBranchName'