Author: gnuhpc
Source: http://www.cnblogs.com/gnuhpc/
Color is selected by adding a special sequence-basically a numerical value between "/E [" and "m. If more than one numeric code is specified, separate them with semicolons.
Echo-e "/E [31; 40 m"
The first digit (31) is the foreground color (red), and the second digit is (40) the background color (black)
Echo-e "/E [0 m"
We need to use the "/E [0 m" sequence to reset the color to the normal value.
/033 [30 m --/033 [37 m sets the foreground color (font color)
/033 [30 m change the color of the character to black
/033 [31 m change the color of the character to red
/033 [32 m change the color of the character to green
/033 [33 m change the color of the character to light red
/033 [34MChange the color of the character to blue.
/033 [35 m change the character color to purple
/033 [36 m change the character color to light blue
/033 [37 m change the color of the character to gray
/033 [40 m --/033 [47 m set the background color
/033 [40 m set the background color to black
/033 [41 m set the background color to red
/033 [42 m set the background color to green
/033 [43 m set the background color to light red
/033 [44 m set the background color to blue
/033 [45 m set the background color to purple
/033 [46 m set the background color to light blue
/033 [47 m set the background color to gray
For example, echo-ne "/033 [32 m" can change the color of the character to green.
Printf () color settings
--------------------------------------
Printf ("/033 [1; 33 m Hello world./033 [0 M/N ");
The color is as follows:
None = "/033 [0 m"
Black = "/033 [0; 30 m"
Dark_gray = "/033 [1; 30 m"
Blue = "/033 [0; 34 m"
Light_blue = "/033 [1; 34 m"
Green = "/033 [0; 32 m"
Light_green = "/033 [1; 32 m"
Cyan = "/033 [0; 36 m"
Light_cyan = "/033 [1; 36 m"
Red = "/033 [0; 31 m"
Light_red = "/033 [1; 31 m"
Purple = "/033 [0; 35 m"
Light_purple = "/033 [1; 35 m"
Brown = "/033 [0; 33 m"
Yellow = "/033 [1; 33 m"
Light_gray = "/033 [0; 37 m"
White = "/033 [1; 37 m"
Author: gnuhpc
Source: http://www.cnblogs.com/gnuhpc/