Monthly Archives: November 2014

bash colors cheat

Black 0;30 Dark Gray 1;30
Blue 0;34 Light Blue 1;34
Green 0;32 Light Green 1;32
Cyan 0;36 Light Cyan 1;36
Red 0;31 Light Red 1;31
Purple 0;35 Light Purple 1;35
Brown/Orange 0;33 Yellow 1;33
Light Gray 0;37 White 1;37

echo -e “\e[;31mI love \e[;1;32mcolors\e[0m \e[;0;34m so \e[;1;30m much. \e[0m”

\e[0m -> No Color

You can also use tput:

echo “$(tput setaf 1)Red text $(tput setab 7)and white background$(tput sgr 0)”

Foreground & background color commands:
tput setab [1-7] # Set the background colour using ANSI escape
tput setaf [1-7] # Set the foreground colour using ANSI escape

Colors are as follows:

Num Colour #define R G B

0 black COLOR_BLACK 0,0,0
1 red COLOR_RED 1,0,0
2 green COLOR_GREEN 0,1,0
3 yellow COLOR_YELLOW 1,1,0
4 blue COLOR_BLUE 0,0,1
5 magenta COLOR_MAGENTA 1,0,1
6 cyan COLOR_CYAN 0,1,1
7 white COLOR_WHITE 1,1,1