A Quick Guide to Some Xterminal Settings

This one comes under the category of a page I put up for myself so I don't have to look it up each time I do a new installation. I hope that it may be of some use to others as well.

I found that in Gentoo Linux, my default xterm was xterm. In FreeBSD, it was sometimes xterm and sometimes kterm (a terminal that can be used to input Japanese). This caused a few minor annoyances, cosmetic more than anything else, but still, it was something that I wanted to fix.

I use rxvt as my xterminal of choice. It allows reading and writing of Japanese and uses fewer resources than does the standard xterm. (I'm not sure if this is true if one starts getting into the real eye candy, such as picture or transparent backgrounds, but, like many, although I liked those at first, I quickly tired of them and went back to my preferred black background with white lettering.)

There were two other issues. One was that the default for rxvt, at least as time of writing, was, in both Gentoo Linux and FreeBSD, a white background with black lettering. The second minor problem was that its default size, like xterm, is 80x24. This is usually fine, however, there are times, for example, when I open mutt, where I want a taller terminal--I have many folders in my .maildir (or Mail in FreeBSD) and need a height of 29 to see them all.

I've not used KDE or GNOME for awhile. Some searching for answers to my questions indicate that the solutions I offer below may not work with them--however, there may be other ways to customize your terminal in both of them. Still, though most of us begin with one or the other, as we get more experienced, we often choose a lighter and faster window manager--in my case, I've pretty much settled on Fluxbox--and the solutions below will work.

So, problem one was to make sure that my default terminal was rxvt. Even if I opened rxvt, when I typed

echo $TERM

I'd get the result of xterm. The problem here was that if I was using mutt, for example, it wouldn't give me colors. Aside from cosmetics, I find that colors make it easier to find certain parts of the headers, etc. So, step one was to set my TERM to rxvt. While this can be done at the command line, I didn't want to worry about it each time. So, with your favorite text editor, create a new file called .Xresources in your home directory. Enter the following (assuming you want rxvt as your TERM).

XTerm*termName: rxvt

If you open up a new rxvt terminal and again do echo $TERM it should now tell you that the TERM variable is set to rxvt. A note on syntax here--when I was researching this, older posts indicated that it used to be TermName rather than termName--however, when trying it that way, it didn't work. The current rxvt man page shows it as termName.

So, that was problem one solved. The second issue was getting a white foreground and black background instead of the default, which is the reverse. So, once again, open up your .Xresources file. Add the lines

Rxvt*foreground: white
Rxvt*background: black

Now, each terminal opened will have the foreground and background you desire.

If you must have that transparent background, which I freely admit can be fun for awhile then add the entry

Rxvt*inheritPixmap: True

My last issue was that I had a little script that ran fetchmail and then opened mutt. However, mutt would open in a standard sized rxvt terminal, which, as mentioned above, was too short for my needs. My original script was

fetchmail && mutt

I changed it to read

fetchmail &&
rxvt -g 80x29 -e mutt

The -g flag stands for geometry and allows me to specify the size. The -e flag stands for (I assume) exec and is used before the name of a program that one wants executed in the rxvt terminal.

Depending upon distro, one sometimes has trouble with the backspace key--I believe that Linus, in an interview, once said that was the one thing he would have done differently.

Sometimes, hitting the backspace key will produce something like ^H or ^?. I've never looked deeply into keymappings, but my quick fix is usually to add to that .Xresources file

Rxvt*backspacekey: ^H

This seems to fix it most of the time--other times, substituting ^? works better, depending upon distro. Other times, it had no effect, and i changed that to

Xterm*ttyModes: erase ^H

I've also, same distro, another box, found that that didn't work and I had to change that to erase ^?. So, it can vary

I should point out that there are other ways to do most of these things--for example, in Fluxbox, one can add the -fg and -bg flags to the fluxbox menu or to an ExecCommand in the keys file. It can also be added to .bashrc. However, this struck me as the easiest. I should add that one can use .Xdefaults rather than .Xresources with the same results.

A quick note on NetBSD. It seemed to ignore .Xresources or .Xdefaults, and needed to have the settings put in /usr/X11R6/lib/X11/app-defaults/Rxvt.

Slackware, and Vector Linux, based on Slack, also seem to have a bit of weirdness. I usually use zsh as my shell of choice, and I was finding that though it worked perfectly in console, it wasn't working in X. The backspace and delete keys for example, wouldn't work regardless of what I had in .Xdefaults. Some playing around solved the problem. Changing termName to xterm-color fixed the issue. Suddenly, zsh worked as it should. (Oddly enough, bash and ksh always worked.) I'm not sure what the problem was, though some googling indicated that it might have to do with xmodmap or perhaps termcap or terminfo. At any rate, whether it's a kludge or not, changing termName fixed it.