Use Terminal Colors to Prevent Errors

As administrators, we often are working on more than one system at a time. If you use screen as much as I do, you may find that all screens are indistinguishable from one another. This becomes a perfect place to separate the different systems into one or more xterms with different colors. You could try to use GNU screen colors (by adjusting the termcap and terminfo entries) but using xterm’s color set is easier.

Using multiple xterms (or rxvt terminals) you can color them in different ways to represent different systems. With different xterm windows, you can also separate the windows in space by putting them in different areas of the screen.

You can also set the backspace key when you start up an rxvt session. Use the –backspacekey option with the appropriate string (such as “^H”). Combined with the background and foreground colors, you could start rxvt with a command like:

rxvt -bg LemonChiffon -fg Black --backspacekey "^H"

The names of the colors can be seen in the file rgb.txt included with X11; in Red Hat Enterprise Linux, it can be found in /usr/share/X11/rgb.txt. For some reason, Ubuntu doesn’t have this file; it seems to be expected by many programs in either /etc/X11/rgb.txt or the previously mentioned /usr/share/X11/rgb.txt. For some strange reason, the folks at Ubuntu refuse to load it into the base; here is a bug report that showcases some of the back and forth on the topic. You can download the current rgb.txt and put it into the correct path if you have to.

My favorite colors for backgrounds – easy on the eyes, easy to read black text – are these:

  • LemonChiffon
  • SkyBlue
  • PowerBlue
  • IndianRed
  • Plum1
  • PaleTurquoise

There are complete lists of X11 colors on the web, such as this page or this page – or this sortable table of colors.

You can also see the colors through the use of the programs xcolors and xcolorsel, both of which do similar things. Both are available as packages for Ubuntu and both require rgb.txt which is probably missing. There don’t seem to be RPM packages for Red Hat Linux (and variants) xcolors or xcolorsel for some reason, although both OpenSUSE and Mandriva look like there should be some current packages for these programs.

3 thoughts on “Use Terminal Colors to Prevent Errors”

  1. When using GNU screen you can add a statusbar with current hostname.
    Just put the following line:

    caption always “%{yK} -=%H=- | $LOGNAME | %{yK}%c | %{yK}%-Lw%{yK}%50>%{Ky}%n%f* %t%{-}%+Lw%<%{- Wk}"

    in the ~/.screenrc file

    %{yK} – foreground yellow, background black
    %H – hostname
    $LOGNAME – logged in username
    %c – clock
    rest of the line – list of windows and so on.

    Best regards

    1. This is certainly true; however, it is not as “in your face” as changing the background. It is also much easier to cover up the name of the server on a status bar than it is to cover the entire window and background.

  2. I’d suggest Mac users look at SetTerminalStyle http://blog.omnigroup.com/2007/11/03/terminal-scripting-in-105/ I use it to make sure I’m aware that I’m running a program inside a sudo shell, and not to screw up. I also have it flag that I’m ssh’ed to a remote server, to remind myself to watch what I type. Relevant part of .bash_login:

    if [ “$TERM_PROGRAM” = “Apple_Terminal” ]; then
    function ssh {
    SetTerminalStyle ssh
    /usr/bin/ssh “$@”
    SetTerminalStyle default
    }
    function sudo {
    SetTerminalStyle sudo
    /usr/bin/sudo “$@”
    SetTerminalStyle default
    }
    fi

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: