Wikia

Vim Tips Wiki

Show a useful title on exit in an xterm

Talk0
1,610pages on
this wiki
Revision as of 09:16, September 29, 2008 by JohnBot (Talk | contribs)

Tip 718 Printable Monobook Previous Next

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.

let &titleold=getcwd()

Should be simple to extend to include other information as well.

Comments

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.


To set title back to the OS type:

if &term != "builtin_gui"
  let &titleold=substitute(system("uname"),'\(.*\)\n','%\1%','')
  set title
endif

Advertisement | Your ad here

Around Wikia's network

Random Wiki