Ever started a couple of xterms or screens and wondered what you were doing in it? You know, like, you start editing httpd.conf file in one, reading man page of httpd in another, ftp to a server in a third window and so on? I get lost. That’s why you can set the title of xterm window and see in title bar where you are, as well as choose a window from a screen window list.
The following applies to zsh.
In .zshrc file implement following two functions:
local PWD=$(print -P "%~")
precmd () {
echo -n "\e]0;[ $USER@$HOST ] ( $PWD )\a"
}
preexec () {
echo -n "\ek[$USER@$HOST]($PWD) - $1\e\\"
}
This way, you get a nice [myname@mymachinename](mycurrentdir) xterm title. Screen title in window list has a little extra – last executed command in addition to the above (like “vi .zshrc”).
There are other ways and syntaxes to do this; this works for me.
Note: you might need the following line in your .screenrc to make the above work.
termcapinfo xterm 'hs:ts=\E]0;:fs=07:ds=\E]0;screen07'