Explorar o código

Improve tmux window update

Viktor Grahn %!s(int64=3) %!d(string=hai) anos
pai
achega
c62370ccf4
Modificáronse 1 ficheiros con 6 adicións e 1 borrados
  1. 6 1
      .vimrc

+ 6 - 1
.vimrc

@@ -251,10 +251,15 @@ nmap <Space>p :GitGutterPrevHunk<CR>
 
 " Setting title to enable better tmux titling
 if exists('$TMUX')
-  autocmd BufReadPost,FileReadPost,BufNewFile,BufEnter * call system("tmux rename-window 'vim | " . expand("%:t") . "'")
+  autocmd BufReadPost,FileReadPost,BufNewFile,BufEnter * call UpdateTmuxWindow()
   autocmd VimLeave * call system("tmux setw automatic-rename")
 endif
 
+function UpdateTmuxWindow()
+  let title = @% == "" ? "vim" : "vim | " . expand("%:t")
+  call system("tmux rename-window '" . title . "'")
+endfunction
+
 function! PrettyXML()
   set filetype=xml
   silent %!xmllint --format --encode UTF-8 --recover - 2>/dev/null