Desktop FreeBSD Part 7: Terminal Emulator Settings

By Ed Hurst | Posted at 11:08 PM
To really take advantage of the best tools in computing requires that you become quite comfortable with using the command line interface (CLI). In general, nearly every task -- aside from graphical work itself -- can be accomplished from the CLI. Once the user becomes more adept at CLI work, these non-graphical tasks can be done more quickly, with more fine-grained control, and with less demand on computer resources.

Even among ordinary desktop users of FreeBSD, there are those who almost never start the X server. However, most of us simply access that part of the system through "terminal emulators," also called "terminal windows." In KDE, the typical terminal emulator is Konsole, though it is not quite the same as a console. We call them "emulators" because there is a great deal of similarity between a console and a terminal emulator, but the latter are still controlled by the X server, and the two exhibit different behaviors in general. At this point, those differences are not really important. Rather, it is the differences between the various terminal emulators that matter to us.

There are two areas of configuration for the terminal emulators that contribute to ease of use: keystrokes and color text.


We have mentioned previously Anne Barreta's guide to sane keyboard settings. Just getting your DEL and BKSP keys to work as you expect is no simple task. What we have today is the result of a system established long ago by folks who had different hardware than is commonly available today. There were dozens of keyboards and dozens of terminal types, each with their own peculiar behaviors, and few bearing much resemblance to what the average home computer has. Most computer users today have been conditioned by one computer culture, and the folks who write Open Source were affected by another. The latter tend to preserve the defaults to what they were for that institutional equipment. That doesn't mean we ordinary desktop users can't have it our way, but that we have to do a little work to get it.

I could not add anything to Anne's work. What I will do here is extract the most common issues for desktop users. It's been my experience that for Konsole, if you choose the keyboard setting for XTerm 4, you will usually get what you expect. On the menu at the top of the Konsole window, select "Settings" and, then "Keyboard" then "XTerm (XFree 4.x.x)" and you should get on the commandline a BKSP key that rubs out the previous character going backwards, and DEL will remove whatever is under the cursor. However, with an XTerm, that's not so simple.

There are a handful of configuration files in your home directory that we call "dot files" because they are named with a dot or period at the front, which keeps them normally "hidden" out of sight. In the one named .Xdefaults, you need to put these lines:

xterm*VT100.Translations: #override 
             BackSpace: string(0x08)
 Delete:    string("33[3~")
             Home: string("33[H")
             End: string("33[F")
*ttyModes: erase ^?

This will tell XTerm what you want those keys to do, along with the END and HOME keys. Now when you are typing on the command line, you can use those keys as you might expect: HOME takes the cursor back to beginning of the line, and END takes it out to the end. Then, we need to add a few lines to a file named .inputrc:

#For XTerm
"e[1~": beginning-of-line
"e[4~": end-of-line
#for rxvt and Konsole

Now, when you open XTerm or Konsole on your desktop, all the keys will tend to work as you expect. In some console applications they will also work that way. Anne explains how to work with different ones in her tutorial.

What we are doing is telling the system to translate the signals from the keyboard into certain actions. The whole thing is really quite complicated, and for the most part, over my head. The strange characters between the quotation marks in these files are a representation of the signals coming from the keyboard under differing circumstances. If you want to see what any keystrokes do under the various terminals, first type ^V on the command line, then the keystrokes you are testing. It works for any combination that you can press at one time. This can help you decide what to put in various configuration files.

But why go to all this trouble for XTerm when Konsole is already setup? In part, it's that issue of resources again. To use Konsole takes more power than a simple XTerm, especially if you are not using KDE. To use Konsole outside KDE requires that a part of KDE be fired up. Also, there are some things in Konsole that cannot be adjusted as they can be for XTerm. For example, you may recall I stated that I have tweaked my .joerc so that I can use comfortable keystrokes to get what I want while editing. For example, if I run Joe in XTerm, I can hit CTRL+HOME and move the cursor to the top of the file. That won't work in Konsole.


In order to get your less command to display more than the most basic ASCII character set, add this line to your .bashrc file:
   export LESSCHARSET=iso8859

Of course, if you prefer some other language, simply take at look at the manual page ("manpage") for the less command by typing on the command line of your terminal window:

   man less

and somewhere in the options you will see a list of for that. With other terminal applications, you'll need to create a file in your home directory named .login_conf (don't forget the leading period) if it's not already there and add a couple of lines like this:


If your preference is not English with an extended character that includes most European language characters, then you need to check the directory at /usr/share/locale/ and you'll find a list of language groups that can be used for the :lang= line; the options for :charset= are available in the fonts.dir file in your system display font sets:

   cd /usr/X11R6/lib/X11/fonts/misc/
   less fonts.dir

If you don't see anything you recognize, just match it with the suffix of your language choice, but change the format to lower case and put in the appropriate hyphens. This article is not the place to explore all the various national character sets.


It was learned long ago that file operations were simpler if the listing of files and folders was color-coded. We learned the ls command to get a list of the files an any directory in the console. If you type that command, it will show the directory where you are working at the time. You can tell it to list any directory you name. For example, if you type

   ls /etc

it will show the files and folders in the /etc folder. How can you tell which is a folder, and which is a file? Try adding the -G option to ls and it should give you names in color: files the same as the plain text, and folders in blue. If you like this option as the standard, you can give the ls command an "alias" that makes it work that way all the time. In your .bashrc, add this line at the bottom of the file:

alias ls="ls -G"

This means that the ls command will always assume you want the -G option inclueded.

By default, Konsole generally allows color text display when it is called for by the choice of commands. Those colors are somewhat muted compared to other terminal emulators. Most of the colors reflect old standards long established. This was done on consoles that were black in the background, and the default text was a bright gray, not quite white. If you use a color scheme that is different from that, text colors may not work just right. When you first open a Konsole, it's usually white in background, and the text is black. I personally find this annoying and change it. Simply open the "Settings" in the Konsole menu, then "Schema" followed by "Linux colors" to get that older style.

For XTerm, you can learn something about it by typing the simple command env and seeing a list of "environment settings." One of them should included mention of TERMCAP followed by a description of the Color XTerm (xterm-color). This shows that your standard XTerm window is set up to display color text. Again, getting your XTerm to show that color-on-black schema requires putting some lines in your .Xdefaults file:

xterm*background: black
xterm*foreground:       gray
xterm*cursorColor: SkyBlue
xterm*font:     9x15
xterm*ScrollBar: on
xterm*SaveLines: 3500

All of these settings are explained in detail if you can wade through the XTerm man page (man xterm). Each of these is human readable up to a point. I happen to favor a pale blue cursor block. The font is a standard terminal font and the size is appropriate for all but the smallest monitors. The SaveLines setting allows you to scroll back up a ways to see what was printed on the screen for 3500 lines. All of these can be adjusted to suit your tastes. The quickest way to learn color names for your system is to install "xcolorsel" (/usr/ports/x11/xcolorsel). This application will display blocks of color with their system names. In KDE, the KColorSel application (under "Graphics" in the menu) will allow you to choose colors by their numerical code; simply copy the code in the small window marked "HTML" along with the hash-mark (#). XTerm will read that format as well for color settings.

You can also install the RxVt terminal (/usr/ports/x11/rxvt), which is a little lighter on resources than either XTerm or Konsole. It does things a little differently, such as displaying color in the man pages instead of bold and underlined text. You can study how to customize that with its own man page (man rxvt).

One final note on terminal emulators. Because we are using the Bash Shell, we have some interesting options for customizing what shows up as our prompt on the command line. I've seen some that were downright extravagant. I prefer a small amount of color coded information. If you put this line in your .bashrc:

export PS1="[33[0;36m]u@h[33[0m]w[33[1;33m]>[33[0m]"

your prompt will display the user name, the "at" symbol (@) and the name of your computer, all in cyan. The directory where you are will be displayed in the default text color, and the whole thing ends in a yellow arrow-head marker, or greater-than sign. To learn how to create your own custom Bash prompt, simply look up the Bash-Prompt-HOWTO on the Internet. You can find it wherever Linux documents are hosted. These include:

Ed Hurst is Associate Editor of Open for Business. Ed is also the Music Director for Grace Baptist Church of Kickapoo Creek, Texas. He loves computers, runs FreeBSD and GNU/Linux and reads all sorts of things. You can reach Ed at