Browse Source

Improve tmux window update

Viktor Grahn 3 năm trước cách đây
mục cha
commit
c62370ccf4
1 tập tin đã thay đổi với 6 bổ sung1 xóa
  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