October 06, 2005

Configuring Xterm in Linux

Xterm is a terminal which runs in X. In linux when you open xterm, you get a small window with a small - hard to read - font by default. Compared to the ordinary xterm, the gnome-terminal and konsole come loaded with lots of features and are good to view. So why would anybody use an xterm over the other two? The answer lies in its low memory foot print. While konsole takes a whooping 8MB and gnome-terminal over 3MB of memory, you can run xterm under 1MB which makes it blazingly fast even when your computer has only 64MB of RAM.

Configuring Xterm Fonts

Here I will explain a number of ways in which you can configure xterm to make it look good and easier to read with larger fonts.

If you look in the man page of xterm, you will find that you can configure the following aspects of xterm, namely :
  1. Text colour
  2. Font family
  3. Font size
  4. The xterm window position w.r.t the desktop
and much more.

Choose the font type and size of xterm Window

The first thing you to do is decide on your choice of font and its size for your xterm. This can be achieved by running the command xfontsel as follows:

$ xfontsel

This will open an X window where you can decide on the font type and size. Once you have decided, note down the values as shown in the xfontsel dialog box. It will look something like this ...

-*-fixed-medium-r-*-*-18-*-*-*-*-*-iso8859-*

...if you have selected a fixed, medium 18pt regular font with iso8859 support.

These values will be used while starting xterm.

To specify the size and position of the xterm window, you can use the -geometry option.

Next test your settings. Execute xterm with the following settings:

$ xterm -font -*-fixed-medium-r-*-*-18-*-*-*-*-*-iso8859-* -geometry 70x24

You will find that it opens with better font clarity. But it is very tedious to run the above command each time you want to open xterm. So you create an alias for it and enter the following line into your .bashrc or .bash_profile file. I have entered it in the .bashrc file in my home directory.

#File: ~.bashrc
alias xterm='xterm -font -*-fixed-medium-r-*-*-18-*-*-*-*-*-iso8859-* -geometry 70x24'

The next time you type xterm, your system will execute the program with the options in your .bashrc file in your home directory.

There is another more powerful way to achieve the same. That is to pass the parameters to your X server so that it will know how to display your xterm when you execute it. This is as follows:

Create a '.Xresources' file in your home directory and enter the values that you want to set.

My .Xresources file is as follows:

# File : .Xresources
xterm*font: -*-fixed-medium-r-*-*-18-*-*-*-*-*-iso8859-*
xterm*font1: -*-*-*-*-*-*-2-*-*-*-*-*-*-*
xterm*font2: -misc-fixed-*-r-normal-*-8-*-*-*-*-*-iso8859-*
xterm*font3: -b&h-lucidatypewriter-bold-*-*-*-12-*-*-*-*-*-*-*
xterm*font4: -*-screen-bold-r-normal-*-16-*-*-*-*-*-iso8859-*
xterm*font5: -*-lucidatypewriter-medium-*-*-*-18-*-*-*-*-*-*-*
xterm*font6: -*-lucidatypewriter-medium-*-*-*-20-*-*-*-*-*-*-*
xterm*font7: -dec-terminal-bold-r-normal-*-14-*-*-*-*-*-iso8859-*

XTerm*background: white
XTerm*foreground: black
XTerm*pointerColor: red
XTerm*pointerColorBackground: black
XTerm*cursorColor: navy
XTerm*internalBorder: 3
XTerm*loginShell: true
XTerm*scrollBar: false
XTerm*scrollKey: true
XTerm*saveLines: 1000
XTerm*multiClickTime: 250 

As you can see in my .Xresources file above, I have set my xterm to start with a fixed font, white background and black foreground and with no scrollbar.

I have also set other settings like the number of lines to save in history and so on.

Note: Instead of the above method, you can alternately do the following to get the same effects.

Create a file say .x_settings - the file can have any name - and copy the contents of .Xresources to it. Now each time you start an X session, type the following command in the console :

$ xrdb -merge .x_settings

Another method to increase the font size of the xterm is by pressing [Ctrl] key and the right mouse button simultaneously while you have focus in xterm window. Then a pop-up menu will come up which can be used to set the font size to your taste. By pressing [Ctrl] key and the middle mouse button, you get a pop-up menu which helps you set/unset a lot of other features of your xterm window like enabling/disabling the scroll bars and so on.

Here I have explained some of the methods by which you can configure xterm to look good. Of course, GNU/Linux is all about the freedom of choice. So xterm is not the only light weight x terminal around.

Two other x terminals which are light weight and having even more features like support for transparency that come to mind are eterm and aterm.

But the advantage of xterm is that you can be sure of having it in all linux distributions by default where as if you want to use aterm or eterm, you may have to download them from their site and install it in your machine.

15 comments:

Josh said...

I was pouring through the xterm man page forever just trying to make my fonts readable. This helped me out a lot! Thanks. -Josh

Anonymous said...

Helpful to have this bird's eye view for a quick alteration for someone who doesn't want to dig through the morass of documentation. Thanks! -John

Anonymous said...

Nice post, easy to follow and succint, with immediate positive effect on my user experience with cygwin. Thanks!

Anonymous said...

This tip help my eyes a lot. Thank you so much for sharing :D

RubiX01 said...

Great tips!

Anonymous said...

Thanks, the xterm manpage is frustratingly complex. I spent a lot of time trying to figure out a way to increase the font size to something readable, but finally gave up. Very useful. Thanks.

grinch said...

mate, i wish i came across your blog 2 hours ago, as i've just wasted them trying to figure out how to change fonts by reading that huge xterm man page. thanks a lot!!!!

Anonymous said...

very clear and useful.
Thanks a lot!

sql said...

i use xterm beacause it work fast and not need memory. i read manual. and manual do not have useful information how to change font size.

very big thank you for your help!)

Anonymous said...

Thanks, it was extremly useful. I could set my XTERM's font.

Ramon said...

Fantastic, finaly i know how to do my xterm like i want !!

partha said...

Handy xterm tips.

Guido van Rossum said...

Oh man, you are too nerdy ! Thanks, I spent the whole night yesterday trying to figure out the font adjustments. Well done :)

Pavan said...

Thanks, this makes reading xterm much easier.
-Pavan

Anonymous said...

Point your mouse over the XTerm and press Ctrl key and mouse right button at the same time. You'll get a list of font options. This way you can change Xterm fonts dynamically.

Get Posts via email