Esoteric Tip #4: Custom ANSI colors in Terminal.app

Posted: January 27th, 2011 | Author: | Filed under: Esoteric Tips | 1 Comment »

In this second Esoteric Tip, I focus on a way to improve the way that Terminal.app handles ANSI colors.

There are a set of standard escape sequences that most terminals support and that correspond to the same actions. If you’re really interested in all the gruesome history of the standard, I encourage you to read the Wikipedia page on the subject. Of particular interest in this post are commands of the form “color the text a certain color starting now”. A program can issue these commands to the terminal as it prints; this is what commands like the ridiculously useful colordiff use to output to the terminal in color and emphasize things that it thinks need emphasizing. Unfortunately, while Terminal.app understands these color commands, there’s no way of customizing the colors used, even though there is support for customizing background and text color. This is particularly annoying if you have a custom Terminal color scheme (which I do, more on that in a minute) and your background is, say, gray; dark green on gray looks terrible.

The only way to fix this at the moment is to use SIMBL and essentially hack Terminal.app to do what you want. There’s a lovely little SIMBL plugin call TerminalColours that enables changing what colors map to what color strings.

I like color schemes that are easy on the eyes (understand, I spend a lot of time looking at terminals and text editors) and I’ve grown particularly fond of the Zenburn color scheme. I use it in Emacs all the time, and now I can use it in Terminal.app as well. I found a Zenburn Terminal.app theme, but it didn’t customize ANSI colors and thus looked pretty awful on color terminals.

Blech.

After installing SIMBL and the TerminalColours plug-in, I rooted around in the Zenburn color scheme file that I use for Emacs to determine the right colors to use. Here they are for convenience, in the form “Color: Red, Green, Blue”

Normal Colors Light Colors
Black: 0, 0, 0
Red: 204, 147, 147
Green: 127, 159, 127
Yellow: 224, 207, 159
Blue: 140, 208, 211
Magenta: 220, 140, 195
Cyan: 147, 224, 227
White: 220, 220, 204
Black: 112, 144, 128
Red: 220, 163, 163
Green: 143, 178, 143
Yellow: 240, 223, 175
Blue: 148, 191, 243
Magenta: 236, 147, 211
Cyan: 147, 224, 227
White: 255, 255, 255

After modifying the colors with the handy menu provided by TerminalColour, the terminal is actually readable:

Update: You can download my modified Zenburn terminal theme here (right-click + Save As works best).

No related posts.


One Comment on “Esoteric Tip #4: Custom ANSI colors in Terminal.app”

  1. 1 Diwaker said at 3:31 pm on January 27th, 2011:

    FWIW, I don’t like or use Terminal.app — too much effort to get it to do fairly simple things. 256 color support is still broken. It is slow as hell. I prefer iTerm — its not great, but better than Terminal.