0
@@ -26,7 +26,6 @@ set statusline=[%l,%c\ %P%M]\ %f\ %r%h%w
0
" allow ESC-sequenzes in 'insert-mode'
0
@@ -126,4 +125,129 @@ set statusline=%<[%n]\ %F\ \ Filetype=\%Y\ \ %r\ %1*%m%*%w%=%(Line:\ %l%)%4(%)Co
0
" set statusline=[%n]\ %<%f\ %((%1*%M%*%R%Y)%)\ %=%-19(\LINE\ [%3l/%3L]\ COL\ [%02c%03V]%)\ ascii['%02b']\ %P
0
" set statusline=%<[%n]\ %F\ \ Filetype=\%Y\ \ Fileformat=%{Fileformat()}\ \ %r\ %1*%m%*%w%=%(Column:\ %c%V%)%4(%)%-10(Line:\ %l%)\ %4(%)%p%%
0
" set statusline=%4*%m%3*%<%F%3*%=Christian\ Schneider\ %5*\ Line\et
0
+function! GuiTabLabel()
0
+ let label = '['.tabpagenr()
0
+ " modified since the last save?
0
+ let buflist = tabpagebuflist(v:lnum)
0
+ if getbufvar(bufnr, '&modified')
0
+ " count number of open windows in the tab
0
+ let wincount = tabpagewinnr(v:lnum, '$')
0
+ let label .= ', '.wincount
0
+ " add the file name without path information
0
+ let n = bufname(buflist[tabpagewinnr(v:lnum) - 1])
0
+ let label .= fnamemodify(n, ':t')
0
+function! s:SID_PREFIX()
0
+ return matchstr(expand('<sfile>'), '<SNR>\d\+_')
0
+function! s:GetTabVar(tabnr, varname)
0
+ " Wrapper for non standard (my own) built-in function gettabvar().
0
+ return exists('*gettabvar') ? gettabvar(a:tabnr, a:varname) : ''
0
+" VCS branch name "{{{2
0
+" Returns the name of the current branch of the given directory.
0
+" BUGS: git is only supported.
0
+let s:_vcs_branch_name_cache = {} " dir_path = [branch_name, key_file_mtime]
0
+function! s:vcs_branch_name(dir)
0
+ let cache_entry = get(s:_vcs_branch_name_cache, a:dir, 0)
0
+ \ || cache_entry[1] < getftime(s:_vcs_branch_name_key_file(a:dir))
0
+ let cache_entry = s:_vcs_branch_name(a:dir)
0
+ let s:_vcs_branch_name_cache[a:dir] = cache_entry
0
+function! s:_vcs_branch_name_key_file(dir)
0
+ return a:dir . '/.git/HEAD'
0
+function! s:_vcs_branch_name(dir)
0
+ let head_file = s:_vcs_branch_name_key_file(a:dir)
0
+ if filereadable(head_file)
0
+ let ref_info = s:first_line(head_file)
0
+ if ref_info =~ '^\x\{40}$'
0
+ let remote_refs_dir = a:dir . '/.git/refs/remotes/'
0
+ let remote_branches = split(glob(remote_refs_dir . '**'), "\n")
0
+ call filter(remote_branches, 's:first_line(v:val) ==# ref_info')
0
+ if 1 <= len(remote_branches)
0
+ let branch_name = 'remote: '. remote_branches[0][len(remote_refs_dir):]
0
+ let branch_name = matchlist(ref_info, '^ref: refs/heads/\(\S\+\)$')[1]
0
+ let branch_name = ref_info
0
+ return [branch_name, getftime(head_file)]
0
+function! s:first_line(file)
0
+ let lines = readfile(a:file, '', 1)
0
+ return 1 <= len(lines) ? lines[0] : ''
0
+function! s:MyTabLine() "{{{
0
+ for i in range(1, tabpagenr('$'))
0
+ let bufnrs = tabpagebuflist(i)
0
+ let curbufnr = bufnrs[tabpagewinnr(i) - 1] " first window, first appears
0
+ let no = (i <= 10 ? i-1 : '#') " display 0-origin tabpagenr.
0
+ let mod = len(filter(bufnrs, 'getbufvar(v:val, "&modified")')) ? '+' : ' '
0
+ let title = s:GetTabVar(i, 'title')
0
+ let title = len(title) ? title : fnamemodify(s:GetTabVar(i, 'cwd'), ':t')
0
+ let title = len(title) ? title : fnamemodify(bufname(curbufnr),':t')
0
+ let title = len(title) ? title : '[No Name]'
0
+ let s .= '%#' . (i == tabpagenr() ? 'TabLineSel' : 'TabLine') . '#'
0
+ let s .= '%#TabLineFill#'
0
+ let s .= '%#TabLineFill#%T'
0
+ let s .= '%=%#TabLine#'
0
+ let branch_name = s:vcs_branch_name(getcwd())
0
+ let s .= (branch_name != '' ? branch_name : '?')
0
+let &tabline = '%!' . s:SID_PREFIX() . 'MyTabLine()'