revans/bash-it — pull request #99 by berenm (2012-02-07 23:31:20+00:00)
Title: Improved color framework

Hi,

I wrote some code to make the colors more poweful. The old color variables have been converted using the new function and should contain more or less the same content as before.

There's now some color and echo_color functions that can be called and that will produce ANSI escape codes, by parsing the parameters of the functions.
Functions parameters are parsed until exhausted so they can be put together. For example: $(color red fg bright black bg underline bold) creates some bright red foreground, black background with bold and underline ANSI codes that will be used until $(color reset) (or ${normal}) is found.

It should also be compatible with xterm 256 colors (at least that works on Gnome Terminal, not tested anywhere else).
For example $(color rgb 127 0 0) will (try to) produce half pure red.

I haven't tested anywhere except on my Debian Gnome Terminal, I don't guarantee everything works fine... but feel free to take the code if you want.