Display Your Location in the Window Title

If you use a window system, you can also display location information in the titlebar of your terminal windows. The following discussion explains how to do so for xterm (the X Window System terminal program) and gives some hints for adapting the xterm instructions to other programs.

Several short startup file command sequences are used in this section. If you don't want to type them, you can retrieve them from the archive mentioned in Appendix C, Other Sources of Information. The archive also contains titlebar changing commands for programs other than those discussed here, as well as documentation for the xterm control sequences mentioned below.

Communicating with xterm

You can specify a window title as a command line argument when xterm starts up, or as a resource value in ˜/.Xdefaults, but neither method is satisfactory for changing the title on an ongoing basis as you move around the file system. However, xterm also understands certain control sequences, one of which sets the window title. This sequence can be sent to xterm at any time using echo, and the title can then be changed on demand. For BSD UNIX systems, the echo command to set the window titlebar to title is as follows:

echo -n "ESC]2;titleCTRL-G"

For versions of UNIX based on System V, the command is slightly different:

echo "ESC]2;titleCTRL-G\c"

Both commands suppress the newline that echo normally prints. (A newline is not part of the control sequence; unless you suppress it,

Get Using csh & tcsh now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.