Color / Colour to Unix output


If you want to add some color to your Unix output, use echo ^[[35m then the text you want e.g. Hello

Where ^[ is "ctrl-v escape" then [

The numeric value will depend on your TERM type (combination of text / background).

echo ^[[0m to reset text (see table below).

The available codes are:

  
0
Normal text, foreground and background
1
Bold text
4
Underline
5
Blink
7
Inverse
30
Black foreground
31
Red foreground
32
Green foreground
33
Yellow foreground
34
Blue foreground
35
Magenta foreground
36
Cyan foreground
37
White foreground
40
Black background
41
Red background
42
Green background
43
Yellow background
44
Blue background
45
Magenta background
46
Cyan backgroud
47
White background

You can combine codes in a single escape sequence by separating them with semicolons.

For example, to create a section of text that is bold text with a yellow foreground and blue background, the escape sequence would be:

^[[1;33;44m














No comments:

Post a Comment