
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.
aixtermaixterm recognises the xterm escape sequences.
wsh, xwsh and wintermThese terminals set $TERM=iris-ansi and use the following escapes:
ESCP1.ystringESC\ Set window title to stringESCP3.ystringESC\ Set icon title to stringxwsh escapes see the xwsh(1G) man page.
The Irix terminals also support the xterm escapes to individually set window title and icon title, but not the escape to set both.
cmdtool and shelltoolcmdtool and shelltool both set $TERM=sun-cmd and use the following escapes:
ESC]lstringESC\ Set window title to stringESC]LstringESC\ Set icon title to stringdttermdtterm 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).
hpterm sets $TERM=hpterm and uses the following escapes:
ESC&f0klengthDstring Set window title to string of length lengthESC&f-1klengthDstring Set icon title to string of length lengthA basic C program to calculate the length and echo the string looks like this:
#include <string.h> int main(int argc, char *argv[]) { printf("\033&f0k%dD%s", strlen(argv[1]), argv[1]); printf("\033&f-1k%dD%s", strlen(argv[1]), argv[1]); return(0); }
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