setenv WHOAMI `whoami`As usual, ^[ stands for ESC, 0x1B, ^G is BELL, 0x07 [ed: enter in vi by typing Control-V then either Control-Open Bracket or Control-G.]
setenv HOSTNAME `hostname -s`
if ($?TERM_PROGRAM) then
if ("$TERM_PROGRAM" == "Apple_Terminal") then
alias precmd 'echo -n "^[]2;[$WHOAMI@$HOSTNAME]^G"'
endif
endif
The reason this is a "precmd" alias is to have the title change when 'su root' and/or remote SSH sessions are suspended. On the remote SSH host, it may be necessary to substitute a "TERM" check for "TERM_PROGRAM" ("TERM_PROGRAM" isn't passed over to the remote environment by default.)
Setting the default "Window" prefs to "Active Process Name" and "Command Key" in "Window Settings..." will have the title look like (at least with Terminal.app v1.3.1):
[root@localhost] -- emacs -- -1PS. Don't believe KB Article 107106; Apple's interpretation of $?TERM_PROGRAM is whishful thinking under tcsh.
[Editor's note: There are a few other useful terminal titling tricks on the site as well: 1, 2, 3, 4, 5...]

