# Candy Colored Terminal

Posted on March 18, 2009.

Yesterday I wrote a blog post about adding Mercurial information to your bash prompt. Almost all of the comments on that entry so far have been asking for the colors I used in the Terminal screenshots, so that’s what this post is for.

The first section of this entry will be able overcoming the limitations of the OS X Terminal application. Skip it if you’re using another (better) terminal application.

## The OS X Terminal and Colors

OS X’s Terminal doesn’t support 256-color mode. I have no idea why. Apple, if you’re reading, please fix this. Because of this, if you want to make the colors prettier you’ve only got the 16 ANSI colors to work with.

Once again, Apple fails hard with Terminal.app. You can’t change the 16 ANSI colors — you can only change the default text color and background. Seriously, Apple, what the hell?

To fix this, you’ll need to install SIMBL and TerminalColors. Follow the instructions on those pages and be sure to restart Terminal once you’ve finished. Now you can change the ANSI colors be hitting the “More” button under the text color settings.

## Picking Some Colors

Now that we’ve beaten Terminal.app into compliance, it’s time to pick some pretty colors. I love the Monokai color scheme for TextMate and so I based my choices on that. Here’s what it looks like:

Here are the RGB values I’m using:

• Black: 0, 0, 0
• Red: 229, 34, 34
• Green: 166, 227, 45
• Yellow: 252, 149, 30
• Blue: 196, 141, 255
• Magenta: 250, 37, 115
• Cyan: 103, 217, 240
• White: 242, 242, 242

The window background is just set to plain old 0, 0, 0 with a 95% opacity.

Not all of the colors match the names: “blue” is actually more of a purple, and “yellow” is much more orange. That doesn’t really matter much though because they’re different enough from each other to still be useful.

Now that the colors are set up you can use them in the normal way. Check out this guide if you don’t know how to do that. Here’s the full code for my bash prompt:

UPDATE: I’ve cleaned up the code a lot thanks to the kind folks in #bash on freenode who helped set me straight on bash quoting and escaping. I’ve also switched to using my hg-prompt extension for the repository information.

D=$'\e[37;40m' PINK=$'\e[35;40m'
GREEN=$'\e[32;40m' ORANGE=$'\e[33;40m'

hg_ps1() {
hg prompt "{${D} on${PINK}{branch}}{${D} at${ORANGE}{bookmark}}{${GREEN}{status}}" 2> /dev/null } export PS1='\n${PINK}\u ${D}at${ORANGE}\h ${D}in${GREEN}\w$(hg_ps1)\${D}\n\$ '


I hope this helps! If you’d like to share your color schemes or tell me how to make the code for my prompt a bit less ugly, please find me on Twitter!