6. Appendix: escapes for other terminal types
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.
6.1 IBM aixterm
aixterm
recognises the xterm escape
sequences.
6.2 SGI wsh
, xwsh
and winterm
These terminals set $TERM=iris-ansi
and use the following escapes:
ESCP1.ystringESC\ Set window title to string
ESCP3.ystringESC\ Set icon title to string
xwsh
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.
6.3 Sun cmdtool
and shelltool
cmdtool
and shelltool
both set $TERM=sun-cmd
and use the following escapes:
ESC]lstringESC\ Set window title to string
ESC]LstringESC\ Set icon title to string
6.4 CDE dtterm
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).
6.5 HPterm
hpterm
sets $TERM=hpterm
and uses the following escapes:
ESC&f0klengthDstring Set window title to string of length length
ESC&f-1klengthDstring Set icon title to string of length length
A 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
Next Previous Contents