I use screen quite a lot. In fact, I can't imagine NOT using it, not only because it allows me stay in IRC while not beeing connected, but mainly because I do not like cluttered desktops. Instead of n open xterm, I have one with a screen session handling n'windows'.
The only problem is that having a screen session with, say, 8 'windows' open, gets complex. I can remember the 'CTRL-] 1' maps to my main terminal, CTRL-] 2' to IRC, and a few more. But more often than not I tab through my open screens trying to find the one in the right directory.
To solve this problem, add this in your
case $TERM in
xterm*)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
;;
screen*)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}:${PWD}\007\033k$PWD\033\\"'
;;
*)
;;
esac
This sets the title of your xterm to the current working directory. But if you're running screen, it also sets the name of this screen 'window' to pwd. Which is great, because now you can hit CTRL-] " and get a list of all 'windows' and in which directory they are.
A bit like this:
0 root $
1/home/domm/3united/threeunited.coin.messaging.sms $
2/home/domm/3united/threeunited.coin.messaging.sms/t/sms_http $
3/home/domm/3united/threeunited.coin.connectivity/http/de.nextid $
.
.
.
Now it's easy to find the right screen. Yay!
Original: http://use.perl.org/~domm/journal/30527
I don't know the bash equivalent (I'm sure it has one) but the tcsh man page has a good example (when describing the cwdcmd and postcmd variables) of doing the same thing, but also including the name/arg list of the most recently executed command.
So your xterm/screen title might be:
~/src/> vi foo.c
which I've found invaluable when hunting between different windows.
In zsh, I stick this in my chpwd() function. Works great!
chpwd () {
[[ -t 1 ]] || return
case $TERM in
xterm*)
print -Pn "\e]0;%m:%~\a";;
screen)
print -Pn "\e_%m:%~\e\\"
print -Pn "\ek%m:%~\e\\";;
esac
}
# Initialize.
cd $PWD
Hmmm, wish I'd commented on why I have two lines in there for screen... I can't remember now. The [[ -t 1 ]] bit is to ensure that stdo