I understand you're using tcsh so this probably won't work... Just in case anyone is looking for the bash way to do this.
If your systems (local / remote) are running bash then you can use the "PROMPT_COMMAND" environment variable to set the window title. PROMPT_COMMAND is eval'd before a prompt is displayed.
(in your .bashrc):
export PROMPT_COMMAND='history -a && echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007'
Explanation:
'history -a'
This sets the shell to append to the history file every time a command is completed, rather than when the whole shell is completed. (This is not related to this example).
'echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"'
This echoes the escape code "\033]0;" which sets the window title with "user" @ "host" variables (removing longest match from right to first ".") and then the working directory (substituting '~' for '$HOME').
The above trick will work with any terminal application that supports dynamic changing of window title (which iTerm, Terminal.app, urxvt, aterm, eTerm. xterm etc all do). You can also look into the shell variable "TITLEBAR" in the bash documentation, it is similar.
Have you found a solution that worked for you yet? – Trey Hunner – 2010-05-16T03:48:41.237
No. I tried the suggested answers but they didn't work. That's why I neither accepted them nor upvoted them. – Nathan Fellman – 2010-05-16T06:17:22.737