tmux tabs with name of file open in vim

后端 未结 6 735
孤街浪徒
孤街浪徒 2020-12-04 15:42

I\'m new to tmux and am trying to figure out how to edit the configuration so that windows with vim open show up in the taskbar not as #:vim but as whatever the

6条回答
  •  时光说笑
    2020-12-04 16:30

    As an alternative to other answers which set the tmux window name, you can have vim set the tmux pane title instead. This lets you keep a static window name that you define with tmux new-window -n while having vim change the pane title. You can use #T in set-titles-string to display the pane title, e.g. set-option -g set-titles-string "#W: #T" will display tmux window name and pane title.

    Example vim configuration to change pane title:

    " Teach vim the tmux escape sequences for changing pane title
    " Note the "^[" should be a literal escape code (use `^v` to enter it)
    set t_ts=^[]2;
    set t_fs=^[\\
    
    " Turn on setting the title.
    set title
    
    " The following causes vim to refresh the title each time we change buffers.
    " Otherwise it will only set the title once at startup.
    augroup RefreshTitle
      autocmd!
      " The concatenation of the colon is a hack to prevent vim from
      " interpreting the string as a modeline.
      autocmd BufEnter * let &titlestring = "vim" . ":" . expand("%:t")
    augroup END
    

    Kudos to vim.wikia.com for the t_ts and t_fs guidance and phluks for the autocommand.

提交回复
热议问题