<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <HTML> <HEAD> <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9"> <TITLE>How to change the title of an xterm: Appendix: escapes for other terminal types</TITLE> <LINK HREF="Xterm-Title-7.html" REL=next> <LINK HREF="Xterm-Title-5.html" REL=previous> <LINK HREF="Xterm-Title.html#toc6" REL=contents> </HEAD> <BODY> <A HREF="Xterm-Title-7.html">Next</A> <A HREF="Xterm-Title-5.html">Previous</A> <A HREF="Xterm-Title.html#toc6">Contents</A> <HR> <H2><A NAME="s6">6. Appendix: escapes for other terminal types</A></H2> <P>Many modern terminals are descended from <CODE>xterm</CODE> or <CODE>rxvt</CODE> and support the escape sequences we have used so far. Some proprietary terminals shipped with various flavours of unix use their own escape sequences. <P> <P> <H2><A NAME="ss6.1">6.1 IBM <CODE>aixterm</CODE></A> </H2> <P><CODE>aixterm</CODE> recognises the <CODE>xterm escape</CODE> sequences. <P> <P> <H2><A NAME="ss6.2">6.2 SGI <CODE>wsh</CODE>, <CODE>xwsh</CODE> and <CODE>winterm</CODE></A> </H2> <P>These terminals set <CODE>$TERM=iris-ansi</CODE> and use the following escapes: <UL> <LI><CODE>ESCP1.y<I>string</I>ESC\ Set window title to <I>string</I></CODE></LI> <LI><CODE>ESCP3.y<I>string</I>ESC\ Set icon title to <I>string</I></CODE></LI> </UL> For the full list of <CODE>xwsh</CODE> escapes see the <CODE>xwsh(1G)</CODE> man page. <P> <P>The Irix terminals also support the <CODE>xterm</CODE> escapes to individually set window title and icon title, but not the escape to set both. <P> <P> <H2><A NAME="ss6.3">6.3 Sun <CODE>cmdtool</CODE> and <CODE>shelltool</CODE></A> </H2> <P><CODE>cmdtool</CODE> and <CODE>shelltool</CODE> both set <CODE>$TERM=sun-cmd</CODE> and use the following escapes: <UL> <LI><CODE>ESC]l<I>string</I>ESC\ Set window title to <I>string</I></CODE></LI> <LI><CODE>ESC]L<I>string</I>ESC\ Set icon title to <I>string</I></CODE></LI> </UL> These are truly awful programs: use something else. <P> <P> <H2><A NAME="ss6.4">6.4 CDE <CODE>dtterm</CODE></A> </H2> <P><CODE>dtterm</CODE> sets <CODE>$TERM=dtterm</CODE>, and appears to recognise both the standard <CODE>xterm</CODE> escape sequences and the Sun <CODE>cmdtool</CODE> sequences (tested on Solaris 2.5.1, Digital Unix 4.0, HP-UX 10.20). <P> <P> <H2><A NAME="ss6.5">6.5 HPterm</A> </H2> <P><CODE>hpterm</CODE> sets <CODE>$TERM=hpterm</CODE> and uses the following escapes: <UL> <LI><CODE>ESC&f0k<I>length</I>D<I>string</I> Set window title to <I>string</I> of length <I>length</I></CODE></LI> <LI><CODE>ESC&f-1k<I>length</I>D<I>string</I> Set icon title to <I>string</I> of length <I>length</I></CODE></LI> </UL> <P> <P>A basic C program to calculate the length and echo the string looks like this: <BLOCKQUOTE><CODE> <PRE> #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); } </PRE> </CODE></BLOCKQUOTE> <P> <P>We may write a similar shell-script, using the <CODE>${#string}</CODE> (<CODE>zsh</CODE>, <CODE>bash</CODE>, <CODE>ksh</CODE>) or <CODE>${%string}</CODE> (<CODE>tcsh)</CODE> expansion to find the string length. The following is for <CODE>zsh</CODE>: <BLOCKQUOTE><CODE> <PRE> 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 </PRE> </CODE></BLOCKQUOTE> <P> <P> <P> <P> <HR> <A HREF="Xterm-Title-7.html">Next</A> <A HREF="Xterm-Title-5.html">Previous</A> <A HREF="Xterm-Title.html#toc6">Contents</A> </BODY> </HTML>