My favorites | Sign in
Project Home Downloads Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Project Information
Members
Featured
Downloads
Links

Color is a simple bash shell script that makes it easy to color and format echo'd text. It does this by converting combinations of readable arguments (bold, red, green, underline, etc.) into an ANSI escape sequence that your terminal emulator or console understands.

Usage

color effect [ lt fgcolor ] bgcolor

color list

color -h | --help

where:

fgcolor and bgcolor are one of black, red, green, yellow, blue, magenta, cyan or white.

effect can be any of nm | normal , bd | bold , ft | faint , it | italic , ul | underline , bk | blink , fb | fastblink , rv | reverse , iv | invisible

Preceed the fgcolor with lt to use a light color -- the light or faint intensity effect is not commonly implemented within terminal emulators or consoles.

color off or just color resets to default colors and text effects.

color list displays all possible color combinations.

Examples

  echo "$(color ul)Underlined text$(color off)"
  echo "Make $(color rv)this$(color nm) reverse video text"
  echo "$(color white blue) White text on a blue background $(color)"
  echo "$(color ltyellow green) lt prefix on the yellow text text $(color off)"
  echo "$(color bold red yellow blink) Blinking bold red text on a yellow background $(color)"

Note that results may vary with these standard ANSI escape sequences because of the different configurations of terminal emulators.

Installation

Check out the featured downloads to the right to find the package type that's right for you.

Tarball users

tar xzvf ansi-color-ver.tar.gz should get you started. Then you can make install to install the binary and manpages and make uninstall if you decide you don't need ansi-color anymore.

Debian/Ubuntu users

If you are using a Debian/Ubuntu system, Iain maintains a Launchpad PPA, that you can access by adding the following lines to your /etc/apt/sources.list:

deb http://ppa.launchpad.net/ilowe/ppa/ubuntu intrepid main
deb-src http://ppa.launchpad.net/ilowe/ppa/ubuntu intrepid main

The do the usual apt-get update and you should be able to apt-get install ansi-color.

You can also just download the .deb file on the right and dpkg -i it.

Inspiration and credit

This script was quickly written after I lost the source for Moshe Jacobson's color command. Being compiled, his creation was much quicker but the binary was not portable across the platforms I used. I wrote this in shell script figuring that it would work across the widest selection of command lines.

While the syntax is compatible with Moshe's command, I wanted to add the ability to use multiple text effects and colors in one invocation and add a few more ANSI escape sequences.

Many thanks to Moshe Jacobson.

Also, a big thank you to Ian Lowe for his Debian/Ubuntu installer work.

-alister

Powered by Google Project Hosting