UNIX Hints & Hacks

ContentsIndex

Chapter 7: Displays and Emulations

 

Previous ChapterNext Chapter

Sections in this Chapter:

   

7.1 Terminal Types

 

7.5 Testing ASCII Terminals

 

 

7.11 Control the Mouse with the Keyboard

7.2 Setting Terminal Types

 

7.6 Troubleshooting ASCII Terminals

 

7.9 Killing Resources with xkill

 

7.12 Display from a Remote X Server

7.3 Make Use of stty

 

7.7 Sharing STDIN/STDOUT on Two Terminals

 

7.10 Setting xterm Titlebars

 

7.13 ASCII Table in UNIX

7.4 Hotkeys

 

 

 

 

 

 

 

7.10 Setting xterm Titlebars

7.10.1 Flavors: AT&T, BSD

7.10.1 Flavors: AT&T, BSD

Wouldn't it be nice to be able to have your current path or the hostname displayed at the top of the xterm window? There is a certain escape sequence that can be passed to xterm that updates the property which the window manager needs for the string that appears in the window titlebar.

% echo "ESC]2;Hostname:`hostname`"

The command to display a string in the titlebar is executed by running a simple echo statement. You first echo the escape (ESC) sequence. In some shells and editors, an escape character can be generated by typing Ctrl+V ( ^v). After the escape sequence, a semicolon is required in more recent versions of xterm and cannot be left off. For the string, the hostname of the system you are logged in to is displayed in the titlebar.

The digit 2 indicates to the xterm to change only the title of the window. If the digit 0 is used, the xterm changes both the title and the name that appears in the icon. When the digit 1 is used, just the icon name is changed.

This process can be put into an alias for your favorite command to use. One such way is to display the current working directory in the titlebar every time you change the directory.

alias cd 'cd \!*; echo -n ESC]2\;$cwd'

When the cd command is issued, the shell changes to the directory entered, displays the directory on the titlebar, and displays it at the shell prompt.

Reason

Administrators who constantly work on many workstations and servers throughout their environment need to constantly keep track of the system they are on.

Real World Experiences

There is a very high, and I mean very high, probability that you will accidentally reboot the wrong system. It happens, it shouldn't, but unfortunately it does. We have all done it at some point in our careers and have done it at the worst possible moment with critical jobs running. A constant reminder of where you are and what system you are on helps reduce the chances of an accident. Most admins say that only inexperienced administrators would make a mistake such as that. This might be true. Don't do it for yourself then; set this up for the others who are not so experienced who will be touching your root access. It might be an operator, a less-experienced administrator, or even a vendor. Reduce the chance of mistakes as much as possible.

I have had it happen that, when I wasn't looking, vendors or operators walk up to a system and attempt to halt it without realizing that they are actually on a remote server. Then the next thing I know, my phone goes crazy with calls from upset users. By seeing different hostnames on the windows that are running on the desktop, these people are able to verify that they are on the correct system. Never take any unnecessary risks when it comes to your systems.

UNIX Hints & Hacks

ContentsIndex

Chapter 7: Displays and Emulations

 

Previous ChapterNext Chapter

Sections in this Chapter:

   

7.1 Terminal Types

 

7.5 Testing ASCII Terminals

 

 

7.11 Control the Mouse with the Keyboard

7.2 Setting Terminal Types

 

7.6 Troubleshooting ASCII Terminals

 

7.9 Killing Resources with xkill

 

7.12 Display from a Remote X Server

7.3 Make Use of stty

 

7.7 Sharing STDIN/STDOUT on Two Terminals

 

7.10 Setting xterm Titlebars

 

7.13 ASCII Table in UNIX

7.4 Hotkeys

 

 

 

 

 

 

 

© Copyright Macmillan USA. All rights reserved.