Colors for xterm with white background

Readable yellow with white background (xterm, git)

Problem

Some programs, e.g., git and the Rust compiler, produce output in yellow (at least by default), and that is not readable with a white or bright background in xterm. Cyan is also hard to read.

This page is for users of xterm. If you use a different terminal emulator, the solution given here will not work, although you maybe something similar will.

Short answer

If you do the following, you get these colors:

Append the following lines in the file .Xresources or .Xdefaults in your home directory (on Ubuntu at least the former is a symbolic link to the latter):

xterm*ReverseVideo: off
xterm*background: white
xterm*foreground: black
xterm*color0: black
xterm*color1: red3
xterm*color2: green4
xterm*color3: yellow4
xterm*color4: blue2
xterm*color5: magenta4
xterm*color6: cyan4
xterm*color7: white
xterm*color8: gray40
xterm*color9: red2
xterm*color10: green3
xterm*color11: rgb:a0/a0/00
xterm*color12: blue1
xterm*color13: magenta3
xterm*color14: cyan3
xterm*color15: white
Perform the appropriate one of
  xrdb -merge $HOME/.Xresources
  xrdb -merge $HOME/.Xdefaults
After that, new xterms will have the new colors. .Xresources should automatically be merged into the xrdb when you log in the next time, so if the settings are there, you don't need to repeat that step on every login.

Long answer

The default settings for xterm found on /etc/X11/app-defaults/XTerm-color (shown below) on my Debian 12 system are for a black background and lead to the following colors:

If you now just switch to a white background with the background and foreground settings above, you get:

I.e., the contrast between some of the colors and the background is too little. By adjusting the colors to be darker as shown above, one gets more readable results for white background. git and compilers just change the foreground color, so that works out ok for them.

How the colors come out depends on your screen. So if you don't like how my colors come out on your screen, you can adjust them. You can use one of the color names or use an RGB value as I have done for color11 (yellow3 has too little contrast against white on some of my displays). You can check the result of your experiments by merging the new .Xresources, starting a new xterm and typing, in that xterm:

  #the wget is only needed once
  wget http://www.complang.tuwien.ac.at/anton/xterm-colors/colors.txt
  cat colors.txt

The colors can be used for setting the background of a piece of text, and actually arbitrary combinations of foreground and background are possible. If you use a program that uses the colors for setting the background, the changed colors may result in worse contrast. You can try to adjust the colors for all uses on your display, or invoke an xterm with special settings for this particular usage, with, e.g.:

  xterm -xrm "xterm*color6: cyan2" -xrm "xterm*color14: cyan1"
Alternatively, you can try to configure your application to use different colors (e.g., Using color and mono video attributes in the mutt documentation).

The default colors

Here are the default settings that produce the black background and colors that do not work well with white background (on my screen colors 1, 4, 9, and 12 don't work well on a black background).
xterm*foreground: gray90
xterm*background: black
xterm*color0: black
xterm*color1: red3
xterm*color2: green3
xterm*color3: yellow3
xterm*color4: blue2
xterm*color5: magenta3
xterm*color6: cyan3
xterm*color7: gray90
xterm*color8: gray50
xterm*color9: red
xterm*color10: green
xterm*color11: yellow
xterm*color12: rgb:5c/5c/ff
xterm*color13: magenta
xterm*color14: cyan
xterm*color15: white
Actually, XTerm-color shows the attribute names as *VT100*..., but I have adapted the attribute names to be the same as the names given above.
Anton Ertl