17 July 2008

xterm select/cut characters

I often use Eterm as my terminal. But, it's a little bit heavy and sometimes I use xterm too. Thing is, xterm is not user friendly and the defaults you get by starting it without options are just horrible.

Now, the basic, cosmetic options for xterm are pretty straight-forward. Also, it's usually good to specify '-ls' to make it a login shell. So:
xterm -ls -bg black -fg yellow -g 120x60

will give you a much nicer looking xterm, and bigger too. Green and cyan also make great foreground colors on the black background.

What really drives me crazy about the default xterm though is the way it selects/cuts text when you double click on something. I often have to do a lot of selecting and pasting and the default just divides on nearly every non-alpha character. There is a solution to that, but it's somewhat involved. I'm going to give you the short story here and tell you how to customize it further. (If you want the long story, try "man xterm".)

This is what I'm using:
xterm -ls -bg black -fg yellow -cc 42:48,45-47:48,126:48 -g 120x60

That takes the characters '*', '-', '.', '/', and '~' and makes them part of character class 48, which already includes all alpha-numeric characters and the underscore character.

Now, if you wanted to add other characters to class 48 so that they'll be included in your double-click selects, you just need to find out the ascii code for those characters and add them to your list. You can find the ascii codes from "man ascii". Use the decimal set.

For example, let's say I wanted to add '=', '?', and '@' to my list of characters to be included in selects. I check the ascii man page and find that their codes are 61, 63, and 64, then I'd add them to the character class list like this:
42:48,45-47:48,61:48,63-64:48,126:48

<ctrl-d>

Labels: ,