User Tools

Site Tools


bash:colors:8-bit_colors

BASH - Colors - 8-bit Colors

256 colors.


Format

ESC[ 38;5;⟨n⟩ m Select foreground color
ESC[ 48;5;⟨n⟩ m Select background color

where n is:

  0-  7:  standard colors (as in ESC [ 3037 m)
  8- 15:  high intensity colors (as in ESC [ 9097 m)
 16-231:  6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5)
232-255:  grayscale from black to white in 24 steps

where:

  • 0 is BLACK.
  • 1 is RED.
  • 2 is GREEN.
  • 3 is YELLOW.
  • 4 is BLUE.
  • 5 is MAGENTA.
  • 6 is CYAN.
  • 7 is WHITE.

RED Example

echo -e "\033[38;5;1mThis is in RED"

BRIGHT RED Example

echo -e "\033[38;5;9mThis is in BRIGHT RED"

ANSI Rainbow

for (( i = 0; i < 16; i++ )); do echo -e "\033[38;5;"$i"mHello"; done

bash/colors/8-bit_colors.txt · Last modified: 2021/01/09 13:33 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki