It is easy to dismiss XTerm as primitive and feature-poor when you are used to gnome-terminal, KTerm, and other graphical tabbed terminal emulators. The truth of the matter, though, is that XTerm is full of functionality that most people never even notice. Three examples follow.
Click To Highlight
The default click-to-highlight behavior of XTerm is miserable. Click once, and it highlights nothing. Click twice, and it highlights "word" text, but stops on almost anything that is not alphanumeric. Click three or more times, and you get the whole line, newline character and all.
This makes highlighting things like URLs, hyphenated words, and cryptographic hashes into a click-and-drag operation, which highly efficient command line users often find frustratingly tedious. Luckily, XTerm's click-to-highlight behavior is pretty trivially configurable.
To configure XTerm's click-to-highlight behavior, find your
app-defaults/XTerm file. On FreeBSD, it is located at
/usr/local/lib/X11/app-defaults/XTerm; on Debian GNU/Linux, it is located at
/etc/X11/app-defaults/XTerm instead. Special character matching expressions can be used to tell what kinds of adjacent characters to highlight on a given number of clicks with
onNClicks resource settings, where the
N is actually a number up to five. The
line expression tells it to just highlight the entire line, while
regex expressions allow you to use a limited regular expression syntax to tell it what characters to match when determining what characters are eligible to highlight when adjacent to other eligible characters.
onNClicks resource settings in my
app-defaults/XTerm file look like this:
xterm*on3Clicks: regex [^ \n]+
xterm*on4Clicks: regex .*
Those of you familiar with regular expression syntax will recognize
[^ \n]+ as indicating one or more characters that are not either a space or a newline, and
.* as indicating any number of almost any type of character at all. For XTerm's
onNClicks resources, the
line setting means it should select the entire line, including the newline.
As mentioned in the article," Use pwsafe as a keyboard shortcut driven X tool," XTerm offers a handy security feature that is not present in many other terminal emulator applications. In XTerm's left-click menu (accessed by pointing your mouse at the XTerm window and holding down both the Ctrl key and the left mouse button) is a "Secure Keyboard" option. Selecting that will activate a secure keyboard mode, which can provide some protection against keystroke logging when entering passwords and typing other things for which you might want a little extra assurance of privacy.
When the secure keyboard mode is activated, XTerm uses the GrabKeyboard protocol request to try to ensure that all keyboard input goes directly and solely to XTerm. This means, of course, that while you have the secure keyboard mode turned on, you should not be able to use the keyboard to interact with any other applications; it is usually only suitable to a very brief interaction, such as entering a password. Assuming it is working correctly, this ensures that other applications cannot "listen in" on your interaction with XTerm via the keyboard or execute a "man in the middle" keystroke logging attack.
As an indication that the secure keyboard mode has been turned on, XTerm's color scheme should be "reversed", with the normal background color becoming the foreground (text) color, and vice versa. If it fails for some reason, XTerm attempts to sound the system bell — and if it fails, you should be suspicious of the possibility that something running on the system is misbehaving (like a keystroke logger).
You can read more about this in the XTerm manpage in the sections labeled "Secure Keyboard" and "SECURITY".
Did you know that XTerm has a Unicode mode? Technically, it is a UTF8 mode, but close enough. You can activate it at the command line by using the
> xterm -u8
These days, XTerm ships with the ability to execute it with the
-u8 option, as well as
-class UXTerm, with a simple alternate command:
This gives you the ability to view international character sets using console based applications within your terminal emulator window.
The tip of the iceberg
XTerm's feature set is tremendous. In fact, it might be a little too large for some people's tastes. Because it comes with the X Window System by default, though, it is almost certain to be installed on any computer running an X-based GUI environment. Since it is there, you might consider using it — especially when you see some of the features you may not have known it had.
A stroll through XTerm's manpage, more than four thousand lines long, can reveal many capabilities that might surprise you.
Chad Perrin is an IT consultant, developer, and freelance professional writer. He holds both Microsoft and CompTIA certifications and is a graduate of two IT industry trade schools.