content/blog/2009/03/candy-colored-terminal.html @ 4cf3a64203d2
taimes
author |
Steve Losh <steve@stevelosh.com> |
date |
Wed, 11 Jul 2012 12:04:56 -0400 |
parents |
def464696a83 |
children |
25ec02499fbc |
{% extends "_post.html" %}
{% hyde
title: "Candy Colored Terminal"
snip: "Better colors for the OS X Terminal."
created: 2009-03-18 18:26:28
flattr: true
%}
{% block article %}
Yesterday I wrote a blog post about [adding Mercurial information to your bash
prompt](/blog/entry/2009/3/17/mercurial-bash-prompts/). 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.
[SIMBL]: http://www.culater.net/software/SIMBL/SIMBL.php
[TerminalColors]: http://ciaranwal.sh/2007/11/01/customising-colours-in-leopard-terminal
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:
![Screenshot of my Terminal, with colors.](/media/images{{parent_url}}/terminal-colors.png "My Terminal colors.")
[Monokai]: http://www.monokai.nl/blog/2006/07/15/textmate-color-theme/
[TextMate]: http://macromates.com/
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](/projects/hg-prompt/) for the
repository information.
[this guide]: http://www.ibm.com/developerworks/linux/library/l-tip-prompt/
:::bash
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][twsl]!
[twsl]: {{links.twsl}}
{% endblock %}