Terminal colors

Setting your terminal’s colors is a matter of use and personal preference, but it is generally important that the colors contrast sufficiently to leave text legible. Use of a projector, operating equipment in dark or sunny conditions, and office environments can all impact color choice. My uses favor a dark background with vibrant foreground colors.

The basis for color terminals is commonly related to the ANSI standard that defined eight colors. Modern terminals often support far more colors, but building a palette based on the original eight leaves applications displaying more-or-less as intended. If you deviate too much, you might find a terminal application uses green—rather than red—for a critical alert or places light blue text on a blue background. An example of careful color selection is Ethan Schoonover’s Solarised.

Here are the original eight colors, along with their bold variants (i.e., modifier = 1), which brings the total count to sixteen:

Modifier Value Normal hue Escape code example
0 30 Black printf '\033[0;30mCOLOR\033[0m'
0 31 Red printf '\033[0;31mCOLOR\033[0m'
0 32 Green printf '\033[0;32mCOLOR\033[0m'
0 33 Brown/Orange printf '\033[0;33mCOLOR\033[0m'
0 34 Blue printf '\033[0;34mCOLOR\033[0m'
0 35 Purple printf '\033[0;35mCOLOR\033[0m'
0 36 Cyan printf '\033[0;36mCOLOR\033[0m'
0 37 Light Gray printf '\033[0;37mCOLOR\033[0m'
1 30 Dark Gray printf '\033[1;30mCOLOR\033[0m'
1 31 Light Red printf '\033[1;31mCOLOR\033[0m'
1 32 Light Green printf '\033[1;32mCOLOR\033[0m'
1 33 Yellow printf '\033[1;33mCOLOR\033[0m'
1 34 Light Blue printf '\033[1;34mCOLOR\033[0m'
1 35 Light Purple printf '\033[1;35mCOLOR\033[0m'
1 36 Light Cyan printf '\033[1;36mCOLOR\033[0m'
1 37 White printf '\033[1;37mCOLOR\033[0m'

My color preferences follow. I do not use the full GNOME desktop environment, but many of my applications, including gnome-terminal, follow GNOME’s settings.

  1. Set the TERM environment variable to hold the value xterm-256color.
  2. Run gnome-control-center, and set GNOMEAppearanceStyle to Dark.
  3. Run gnome-terminal, and select Custom in PreferencesColors. Next, customize the following values:
  • Palette entry 0: #000000
  • Palette entry 1: #ff0000
  • Palette entry 2: #00ff00
  • Palette entry 3: #ff8800
  • Palette entry 4: #00ccff
  • Palette entry 5: #ff00ff
  • Palette entry 6: #00ffff
  • Palette entry 7: #f0f0f0
  • Palette entry 8: #888888
  • Palette entry 9: #ff8888
  • Palette entry 10: #88ff88
  • Palette entry 11: #ffff00
  • Palette entry 12: #8888ff
  • Palette entry 13: #ff88ff
  • Palette entry 14: #88ffff
  • Palette entry 15: #ffffff
  1. Edit .vimrc and add colorscheme=koehler.
  2. Edit .muttrc and add the following color definitions (notice mutt expects variants of the ANSI colors):
color hdrdefault red default
color quoted yellow default
color signature red default
color indicator black brightyellow
color error brightred default
color status black white
color tree magenta default
color tilde magenta default
color message brightcyan default
color markers brightcyan default
color attachment brightmagenta default
color search default green
color header blue default ^(From|Subject|To):
color body magenta default "(ftp|http)://[^ ]+"
color body magenta default [-a-z_0-9.]+@[-a-z_0-9.]+
color underline brightgreen default
color index black brightred '~h "X-Spam-Flag: YES"'    # Spamassassin.
color index black brightyellow '~h "X-Bogosity: Spam"' # Bogofilter.

Testing terminal colors involves running various commands and observing the appearance of their output. You should test under the conditions you expect, such as with a projector, in sunlight, or in a dark office. Here are some illustrative commands:

  • mutt
  • dircolors --print-ls-colors (and the LS_COLORS environment variable)
  • grep
  • vim (view various languages and HTML)
  • diff --color
  • git diff
  • git log
  • git status