Created
October 25, 2013 16:37
-
-
Save grauwoelfchen/7157667 to your computer and use it in GitHub Desktop.
tabline with buffers and hostname
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! s:tab_label(n) | |
let bufnrs = tabpagebuflist(a:n) | |
let curbufnr = bufnrs[tabpagewinnr(a:n) - 1] | |
let hl = a:n ==? tabpagenr() ? 'TabLineSel' : 'TabLine' | |
let bufs = len(bufnrs) | |
if bufs == 1 | |
let bufs = '' | |
else | |
let bufs = '%#'.hl.'Number#'.bufs | |
end | |
let updated = len(filter(copy(bufnrs), 'getbufvar(v:val, "&modified")')) ? '+' : '' | |
let blank = (bufs.updated) ==? '' ? '' : ' ' | |
let fname = pathshorten(bufname(curbufnr)) | |
return '%'.a:n.'T'.bufs.updated.blank.'%#'.hl.'#'.fname.'%T%#TablineFill#' | |
endfunction | |
function! MakeTabLine() | |
let labels = map(range(1, tabpagenr('$')), 's:tab_label(v:val)') | |
let separator = " | " | |
let tabs = ' ' . join(labels, separator).separator."%#TablineFill#%T" | |
let info = fnamemodify(getcwd(), ':~').' « '.hostname().' » ' | |
return tabs.'%='.info | |
endfunction | |
set showtabline=2 | |
set tabline=%!MakeTabLine() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment