Many modern terminals are descended from xterm or rxvt
and support the escape sequences we have used so far. Some proprietary
terminals shipped with various flavours of unix use their own
escape sequences.
dtterm sets $TERM=dtterm, and appears to recognise both the
standard xterm escape sequences and the Sun cmdtool
sequences (tested on Solaris 2.5.1, Digital Unix 4.0, HP-UX 10.20).
We may write a similar shell-script, using the ${#string}
(zsh, bash, ksh) or ${%string}
(tcsh) expansion to find the string length. The following
is for zsh:
case $TERM in
hpterm)
str="\e]0;%n@%m: %~\a"
precmd () {print -Pn "\e&f0k${#str}D${str}"}
precmd () {print -Pn "\e&f-1k${#str}D${str}"}
;;
esac