created May 14, 2004 · complexity basic · author Jason P · version 6.0
If you're like me, you go to all the trouble of setting up your shell to put useful information in your xterm title. But on quiting Vim, there is no longer any useful information in the xterm title-- only "Thanks for Flying Vim".
Adding this line to your vimrc will make Vim put the current working directory in the xterm title on exit.
Should be simple to extend to include other information as well.
If you have vim compiled with X support it can restore terminal title itself.
Warning: That will record the cwd where you started vim. If you changed directories in the interim, setting that title will be incorrect. To reproduce:
% vim (Suspend using ^Z) % cd some/where/else % fg :q!
The title will now have the original directory, not some/where/else, which is what it should be.
In addition, the string produced by getcwd() upon exit is static and will not update as you change directories.
To set title back to the OS type:
if &term != "builtin_gui" let &titleold=substitute(system("uname"),'\(.*\)\n','%\1%','') set title endif