Search code examples
vimterminalansi-escape

Set terminal title to current file name and path with Vim


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?


Solution

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