Colors
Text colors (and SGR parameters in general) are manipulated usingCSI n1 [;n2 [; ...]] m sequences, where each n1, n2, ... is an SGR parameter as shown above. Thus, for instance, you use codes 30+i to specify foreground color, 40+i to specify background color, where i is the number in the desired color's column header in the table below. The following examples can be used with the printf utility, where \x1b[ implements the CSI: To switch the foreground color to black, use \x1b[30m; to switch to red, use \x1b[31m; utilizing the "bold" parameter, gray would be \x1b[30;1m; to get bold red, use \x1b[31;1m. To reset colors to their defaults, use \x1b[39;49m (or reset all attributes with \x1b[0m).| Intensity | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|---|
| Normal | Black | Red | Green | Yellow[12] | Blue | Magenta | Cyan | White |
| Bright | Black | Red | Green | Yellow | Blue | Magenta | Cyan | White |
| Color name | Standard VGA colors | Windows XP CMD | Terminal.app | PuTTY | mIRC | xterm | CSS/HTML | X | |
|---|---|---|---|---|---|---|---|---|---|
| Normal | Black | 0, 0, 0 | 0, 0, 0 | 0, 0, 0 | 0, 0, 0 | 0, 0, 0 | 0, 0, 0 | 0, 0, 0 | 0, 0, 0 |
| Red | 170, 0, 0 | 128, 0, 0 | 194, 54, 33 | 187, 0, 0 | 127, 0, 0 | 205, 0, 0 | 255, 0, 0 | 255, 0, 0 | |
| Green | 0, 170, 0 | 0, 128, 0 | 37, 188, 36 | 0, 187, 0 | 0, 147, 0 | 0, 205, 0 | 0, 255, 0 | 0, 128, 0 | |
| Brown/yellow | 170, 85, 0 | 128, 128, 0 | 173, 173, 39 | 187, 187, 0 | 252, 127, 0 | 205, 205, 0 | 255, 255, 0 | 255, 255, 0 | |
| Blue | 0, 0, 170 | 0, 0, 128 | 73, 46, 225 | 0, 0, 187 | 0, 0, 127 | 0, 0, 238 | 0, 0, 255 | 0, 0, 255 | |
| Magenta | 170, 0, 170 | 128, 0, 128 | 211, 56, 211 | 187, 0, 187 | 156, 0, 156 | 205, 0, 205 | 255, 0, 255 | 255, 0, 255 | |
| Cyan | 0, 170, 170 | 0, 128, 128 | 51, 187, 200 | 0, 187, 187 | 0, 147, 147 | 0, 205, 205 | 0, 255, 255 | 0, 255, 255 | |
| Gray | 170, 170, 170 | 192, 192, 192 | 203, 204, 205 | 187, 187, 187 | 210, 210, 210 | 229, 229, 229 | 255, 255, 255 | 255, 255, 255 | |
| Bright/light | Darkgray | 85, 85, 85 | 128, 128, 128 | 129, 131, 131 | 85, 85, 85 | 127, 127, 127 | 127, 127, 127 | ||
| Red | 255, 85, 85 | 255, 0, 0 | 252,57,31 | 255, 85, 85 | 255, 0, 0 | 255, 0, 0 | |||
| Green | 85, 255, 85 | 0, 255, 0 | 49, 231, 34 | 85, 255, 85 | 0, 252, 0 | 0, 255, 0 | 144, 238, 144 | 144, 238, 144 | |
| Yellow | 255, 255, 85 | 255, 255, 0 | 234, 236, 35 | 255, 255, 85 | 255, 255, 0 | 255, 255, 0 | 255, 255, 224 | 225, 255, 224 | |
| Blue | 85, 85, 255 | 0, 0, 255 | 88, 51, 255 | 85, 85, 255 | 0, 0, 252 | 92, 92, 255 | 173, 216, 230 | 173, 216, 230 | |
| Magenta | 255, 85, 255 | 255, 0, 255 | 249, 53, 248 | 255, 85, 255 | 255, 0, 255 | 255, 0, 255 | |||
| Cyan | 85, 255, 255 | 0, 255, 255 | 20, 240, 240 | 85, 255, 255 | 0, 255, 255 | 0, 255, 255 | 224, 255, 255 | 224, 255, 255 | |
| White | 255, 255, 255 | 255, 255, 255 | 233, 235, 235 | 255, 255, 255 | 255, 255, 255 | 255, 255, 255 |
Reference:
http://en.wikipedia.org/wiki/ANSI_escape_code
沒有留言:
張貼留言