Configuring xterm

When I say xterm, I'm talking about Thomas E. Dickey's xterm, which is basically the xterm that you did/do get with XFree86. Just about any modern Unix-a-like will use this as its system xterm.

I keep a set of local customizations in my ~/.Xdefaults file to make xterm look and feel a lot better than its default settings do.

Here it is, in easily digestible (and copy-paste-able) pieces:

First, pick a nice font. I quite like proggy fonts. Also good are Terminus and Triskweline.

xterm*font: -windows-proggyclean-medium-r-normal--13-80-96-96-c-70-iso8859-1

(Note: the above is just an example. You will need to download the font you want to use, add it to your X fontpath, and work out its full name, usually using xlsfonts. Don't add the above line, not install proggy clean, and then wonder why it isn't working. I'm sure someone out there is that stupid)

Next, I like all my terminals having login shells. Having one that isn't a proper login confuses the shell environment. For consistency, I always have:

xterm*loginShell: true

Next, size: I'm very particular about having an 80x50 terminal. 80 columns is not just a good idea, it's the law:

xterm*vt100*geometry: 80x50

Note the vt100 above. If you write out this line without it, the geometry setting will affect things other than the size of the xterm. Like, for example, the Ctrl+Click menu will be 80 pixels wide and 50 pixels tall, rendering it entirely unusable. Thanks to Alex Peters for figuring this out and telling me about it.

Next, I like having lots of scrollback:

xterm*saveLines: 2000

Note that I don't turn on any scrollbars. You can scroll up and down by using Shift+PgUp and Shift+PgDn, respectively. Sun Microsystems always screw this up for me - they switch the meanings of PgUp and Shift+PgUp, so regular PgUp becomes scrolling and you have to "escape" it with a Shift to get the PgUp sent to the underlying application. They even make the gnome-terminal that comes with the Sun Java Desktop behave like this.

Next, I like being able to double-click to select a word. The definition of a "word" depends on the character class resource. I've never bothered to disassemble the following, but it works quite well for me. Much better than the default:

xterm*charClass: 33:48,35:48,37:48,43:48,45-47:48,64:48,95:48,126:48,35:48

Some systems get confused about xterm's TERM type. It's xterm-color. If you're using an outdated OS, like Solaris, you'll need to install the xterm-color terminfo file into the appropriate place. (/usr/share/lib/terminfo/x/xterm-color on Solaris) Get it right:

xterm*termName: xterm-color

If Alt+F sends \346 and you need ^[f, add the following line. I've seen this problem on Ubuntu systems.

xterm*eightBitInput: false

Now the fun bit: I actually really like the DOS-box colors. These are taken from a screen capture:

xterm*foreground: rgb:a8/a8/a8
xterm*background: rgb:00/00/00

xterm*color0: rgb:00/00/00
xterm*color1: rgb:a8/00/00
xterm*color2: rgb:00/a8/00
xterm*color3: rgb:a8/54/00
xterm*color4: rgb:00/00/a8
xterm*color5: rgb:a8/00/a8
xterm*color6: rgb:00/a8/a8
xterm*color7: rgb:a8/a8/a8
xterm*color8: rgb:54/54/54
xterm*color9: rgb:fc/54/54
xterm*color10: rgb:54/fc/54
xterm*color11: rgb:fc/fc/54
xterm*color12: rgb:54/54/fc
xterm*color13: rgb:fc/54/fc
xterm*color14: rgb:54/fc/fc
xterm*color15: rgb:fc/fc/fc

Note that foreground is lightgray (color7) and background is black (color0). Dark text on a light background is evil and wrong.

Next, bold text looks really terrible. I prefer the bold attribute to make the text bright, like it did in DOS, instead of making the font fat and illegible. To do this, disable boldMode:

xterm*boldMode: false

Sometimes this isn't enough and you still get unreadable text. You can work around it by setting xterm*boldFont to the same value as xterm*font above. I've seen this problem on Ubuntu systems.

boldMode makes color+bold = lightcolor, but bold foreground (color7) stays color7. As in, bold now has no effect on uncolored text. I want lightgray+bold = white, so I add:

xterm*colorBDMode: true
xterm*colorBD: rgb:fc/fc/fc

And that's it.

Rant: DOS

Yes, yes, DOS is terrible, blah blah, whatever. I grew up on DOS and it had an awesome default color scheme and lots of cool drawing characters that very talented people could use to make some awesome ANSI art.

Obviously, I much prefer the Unix environment, but one of the things that always irked me about it (before I wasted all this time figuring out how xterm and terminfo and curses play together) is that it just looked bad.

What I'm trying to say is: I think that making an xterm look like a DOS box should not carry the stigma of DOS being DOS. A default xterm looks bad. A default DOS box looks much better.

Rant: How not to configure xterm

At University, we had a very cool shared Unix environment, like back in the good old days. Something I used to see very often, which disturbed me, was people configuring their xterms through their window manager configuration. As in, they would have a menu entry for starting a terminal, and it'd run xterm followed by several wrapped lines of commandline arguments to tweak all the different settings they wanted.

This is the wrong way to do it.

The default resources for an xterm belong in the same place as the default resources for all your other X applications: in a file called .Xdefaults

The benefits of doing it right:

The Debian Xsession(5) manpage says that .Xdefaults is a hangover from X10 and X11R1, and that it should be spelled .Xresources. On some systems you need to use xrdb to [re]load the resources file:

xrdb -merge ~/.Xresources

Rant: Desktop Environments

Konsole and gnome-terminal suck.

Matt Dillon wrote:

gnome is a good test. The gnome-terminal program is a medium-sized cpu hog (it uses four times the cpu that the pine program running under it uses)

And how the hell do you get a gnome-terminal to have a default geometry of 80x50 when it starts!?

Rant: 80 columns or bust

I once spent some time in a 100x50 terminal because I thought using only 80 columns was making me a slave to outdated computing limitations / the patriarchy / the military-industrial complex.

Later, after I'd come to my fucking senses, I had to work on some code that I had written to a width of 100 columns and I really badly wanted to go back in time and kick my own ass!

Do not, do not, do not exceed 80 columns! I wasn't kidding earlier: it's not just a good idea, it's the law!


Valid XHTML 1.1
Copyright © 2006-2009 Emil Mikulic.