Logo
IT Dienstleistungen

Colors in Ansi-Shells

Colors are produced bei simply echoing the following code before the colorized text. Works also in Console-Programs (Ansi C, Java, …)

All colors build with the same sheme:

\033[X;Ym

While \033 indicates the Ansi-Code for „Color“, X = {0, 1, 4, 5} and Y = {30, …, 37, 40, … , 47} could be taking from following table:

Color Control

  • 0 to restore default color
  • 1 for brighter colors
  • 4 for underlined text
  • 5 for flashing text

Textcolors

  • 30 for black foreground
  • 31 for red (or light red)foreground
  • 32 for green (or light green) foreground
  • 33 for yellow (or brown) foreground
  • 34 for blue (or light blue) foreground
  • 35 for purple foreground
  • 36 for cyan foreground
  • 37 for white (or gray) foreground

Backgroundcolors

  • 40 for black background
  • 41 for red background
  • 42 for green background
  • 43 for yellow (or brown) background
  • 44 for blue background
  • 45 for purple background
  • 46 for cyan background
  • 47 for white (or gray) background

What else?

To restore the original terminal color use \033[00m


Seiten-Werkzeuge