How can I get the file that I opened in vim to display on my iTerm tab

I can get the name vim to display in my window by doing the following:

let &titlestring = expand("%:t") . " @ " . hostname() if &term == "screen" set t_ts=^[k set t_fs=^[\ endif if &term == "screen" || &term == "xterm" set title endif 

But the tabs will say "Default."

From the command line, I can do this:

echo -ne "\e]1;hello world\a"

And it will show "Hello World" on my tabs.

Is there a way to get vim to write this stuff to my tab instead of the name?

+6
vim tabs iterm
source share
2 answers

I don't have iTerm, so I can't verify this, but try adding this to your .vimrc :

 set t_ts=^[]1; set t_fs=^G 

Enter CTRL-V Escape for ^[ and CTRL-V CTRL-G for ^G

+4
source share

This is what worked for me:

 " Set the title of the Terminal to the currently open file function! SetTerminalTitle() let titleString = expand('%:t') if len(titleString) > 0 let &titlestring = expand('%:t') " this is the format iTerm2 expects when setting the window title let args = "\033];".&titlestring."\007" let cmd = 'silent !echo -e "'.args.'"' execute cmd redraw! endif endfunction autocmd BufEnter * call SetTerminalTitle() 

Source: https://gist.github.com/bignimbus/1da46a18416da4119778

0
source share

All Articles