Skip to main content
2 of 10
added 1096 characters in body
goldilocks
  • 90k
  • 33
  • 212
  • 272

Those are ANSI escape sequences; that link is to a chart of color codes but there are other interesting things on that wikipedia page as well. Not all of them work on (e.g.) a normal linux console.

\033]00m\] # white

Incorrect! 0 resets the terminal to its default (which is probably white). The actual code for white foreground is 37.

Note that some GUI terminals allow you to specify a customized color scheme. This will affect the output.

There's a list here which adds 7 foreground and 7 background colors I had not seen before, but they seem to work:

# Foreground colors 90 Dark gray 91 Light red 92 Light green 93 Light yellow 94 Light blue 95 Light magenta 96 Light cyan # Background colors 100 Dark gray 101 Light red 102 Light green 103 Light yellow 104 Light blue 105 Light magenta 106 Light cyan 

In addition, if you have a 256 color GUI terminal and:

export $TERM=xterm-256color 

Which may or may not be necessary, but is probably a good thing, you can apply colors from this chart:

enter image description here

The ANSI sequence to select these, using the number in the bottom left corner, starts 38;5; for the foreground and 48;5; for the background, then the color number, so e.g.:

echo -e "\\033[48;5;95;38;5;214mhello world\\033[0m" 

Gives me a light orange on tan (meaning, the color chart is pretty roughly approximated).

goldilocks
  • 90k
  • 33
  • 212
  • 272