Unix - ANSI colors

From NoskeWiki
Jump to navigation Jump to search


NOTE: This page is a daughter page of: Unix

UNIX command line can show a few different colors. They are the ANSI escape code colors shown below.

ANSI Colors List

ANSI Color table
Intensity 0 1 2 3 4 5 6 7
Normal Black Red Green Yellow Blue Magenta Cyan White
Bright Black Red Green Yellow Blue Magenta Cyan White

Use "\e[0;34m" (or "\x1b[0;34m") for blue, "\e[1;34m" for light blue.
Vary first number: 1=alt_color, 3=bold, 4=underline, 7=invert, and so on.

Using with printf

You can output colors to a shell using printf as per this example:

$ printf "My favorite styles are \e[0;31m red \e[0m , \e[1;32m bold green \e[0m and \e[7;44m inverted blue \e[0m \n"

Here are the full color codes to copy:

ANSI codes

Black \e[0;30m White \e[1;37m
Brown \e[0;33m Yellow \e[1;33m
Gray \e[0;37m Dark Gray \e[1;30m
Blue \e[0;34m Light Blue \e[1;34m
Green \e[0;32m Light Green \e[1;32m
Cyan \e[0;36m Light Cyan \e[1;36m
Red \e[0;31m Light Red \e[1;31m
Purple \e[0;35m Light Purple \e[1;35m

Remember that varying the first number ("\e[0;32m") can result in some cool effect like bold (3), underline (4), invert with background (7), crossed-out (9) and so on.

See Also