I use "screen" everyday whether I am on Grml Linux or MacOSX. And also every time I log on to any unix servers, I have to run screen too as it is the best way to keep my sessions safely whenever there is Internet connection disruption.
Normally, when I do coding, I run multiple vim s under screen like this:
The blue status line comes from a setting in my .screenrc :
hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %m/%d %C%a "
As you may notice, all the title of each screen are just the same "vi" even though I ran:
- [screen 0] vi a
- [screen 1] vi b
- [screen 2] vi c
Therefore, I have no idea which file it is unless I switch to that screen which can be cumbersome most of the time.
Luckily, vi can send some special status to shell and screen to display a customized title. All you need to do is to add these lines in your .vimrc file:
let &titlestring = "vi(" . expand("%:t") . ")"
if &term == "screen"
set t_ts=^[k
set t_fs=^[\
endif
if &term == "screen" || &term == "xterm"
set title
endif
Note that the "^[k]" and "^[\" are control characters which you have to enter them by (in vim):
- [in edit mode] ctrl+v => esc => k
- [in edit mode] ctrl+v => esc => \
After that you re-run screen and use vi to open files and it should look like this:
Notice the vi(a), vi(b) and vi(c) - Now they display which file names they are opening!
references:
references:
0 comments:
Post a Comment