Xterm

From LinuxReviews
Jump to navigationJump to search

XTerm is a really simple terminal emulator which has the major advantage of being included in every Linux distribution with a X server. You have it unless you did a bare-bones net-install.

Xterm is the default terminal emulator in BlackArch Linux.

Keyboard shorts you want to know

These are not specific to xterm but useful.

  • ctrl + c will stop/cancel any command running in the terminal
  • ctrl + d will close a terminal window. Quicker than typing exit
  • ctrl + l clears the screen (same as typing clear

Accessing the three Secret xterm menus

Few people are aware that xterm does have menus. You can see the menus by holding ctrl and pressing the left, right or middle mouse buttons to get menus "Main Options", "VT Fonts" and "VT Options".

Setting the font and colors

You can start xterm with the option fn to change the font. fg and bg will change the foreground and background colors. Running command xlsfonts in a temrinal will list fonts available to you.

An example of starting a xterm window with terminus and green text on black would be:

Shell command(s):
xterm -fn "-xos4-terminus-medium-r-normal--32-320-72-72-c-160-iso8859-1" -bg black -fg green

The defaults that are used by xterm are defined in the file /usr/share/X11/app-defaults/XTerm[1]

You can override these defaults by placing your own preferences in $HOME/.Xresources.

Note: Do not use $HOME/.Xdefaults. This file was used historically; it is no longer the way to do it.

An example configuration for green text on a black background and a huge typewriter font would be:

File: $HOME/.Xresources
xterm*foreground:green
xterm*background:black
xterm*font:lucidasanstypewriter-24

$HOME/.Xresources is read once upon starting X so you will have to re-load the file to apply your changes.

You can but should not re-load your Xresources and replace all existing settings with the contents of this file when you have edited it with the simple command:

xrdb $HOME/.Xresources

The right approach is to "merge" your new settings currently in use with new settings you have added or changed by using the -merge- option:

xrdb -merge $HOME/.Xresources

Using -merge may be important depending on desktop environment because desktops like Xfce will set X resource values for things like DPI.

Minor side-note: Most distributions will load $HOME/.Xresources upon login. You can place this in $HOME/.xinitrc if you are using a distribution where that does not happen for some reason:

[[ -f ~/.Xresources ]] && xrdb -merge -I$HOME ~/.Xresources

A last thought on xterm and other terminals

xterm is actually a really powerful and highly configurable terminal. It may not appear that way because it's not immediately apparent that it has menus of configuration options. Thus; most people will simply move on to some other terminal with menus such as konsole. That's fine. Just know that xterm does have a lot of options and it is worth knowing some of them in case you need to do something at a client location where there's nothing but xterm.

notes