7

I would like Vim to send the name of the currently open file to macOS Terminal.

It is possible to tell the macOS terminal the filename of a currently open document by sending the escape sequence \e]6;FILENAME\a. This can be seen be executing the command printf "\e]6;FileName.txt\a"

I would like Vim to send the filename of the currently open document to Terminal. It seems like this should be easy, but :echo "\e]6;FileName.txt\007" will turn the escape sequences into printable characters and add some color to them, so it instead outputs ^[]6;FileName.txt^G which is not recognized by Terminal.

How can I configure :echo not to mangle my escape sequences?

Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
Pat Hawks
  • 383
  • 2
  • 7
  • 5
    See `:help 'title'`. – romainl Mar 20 '18 at 06:34
  • Does this answer your question? [How to send escape sequences from within Vim?](https://stackoverflow.com/questions/32429471/how-to-send-escape-sequences-from-within-vim) – UrsaDK Nov 16 '19 at 21:30

2 Answers2

18

Thank you @romainl; this was as simple as adding set title to my ~/.vimrc file.

Pat Hawks
  • 383
  • 2
  • 7
  • you saved my day! I was using before workaround to run vim like `vim /path/to/file` in order to have terminal tab using correct title.. – zhisme May 31 '22 at 21:40
0
set title 

to the ~/.vimrc file does put the file being edited onto the terminal heading, very useful if several tabs are open.

You can also add

oldtitle=

which will retore the terminals original title. Otherwise VIM wites a "thanks for flying VIM" message on exit.

user50619
  • 325
  • 5
  • 14