Screen and Vim Setup
I love screen. I love vim. One problem I have is that I can't seem to remember which screen session is editing which file. I decided to spend some time and get this fixed, once and for all.
My screen now has a persistent line showing the window setup. Obviously it won't be perfect for the number of windows I run at home, but it's working nicely at work.
The screen line is the last line in my terminal and looks like:
[ hostname ][ 0 mysql 1- tcsh (2*tcsh) ][11:09]
(I'm not spending time showing all the colors here. You could adjust them if you like.)
If you want to use this, put this line in your .screenrc:
hardstatus alwayslastline '%{= kG}[ %{G}%H %{G}]%{g}[%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}]%{G}[%{W}%c%{G}]'
Now, for the vim setup. I've always noticed that my screen titles are useless. They all say 'tcsh' unless I have pre-titled them (like the mysql above). What if vim could change the title for me? As it turns out, it can.
I open a new window and a new file, test.txt. Now my bottom of my terminal shows:
"test.txt" [New File] 0,0-1 All
[ hostname ][ 0 mysql 1 tcsh 2- tcsh (3*vim:test.txt) ][11:14]
Closing the vim session resets the title back to tcsh as well.
If you want this, add the following to your .vimrc:
let &titlestring = "vim:" . expand("%:t")
let &titleold = "tcsh"
if &term == "screen"
set t_ts=^[k
set t_fs=^[\
endif
if &term == "screen" || &term == "xterm"
set title
endif
(Those are escapes ( ^[ ) in the set. Control-v + escape in vim ^^)
If you like this, let me know. Thanks.
Posted by dragon at November 06, 2009 11:16 AM