Shell
Color in
1)
Concept
ANSI
Escape code to control the display format
To
CSI
(
Control sequence indicator
).
Select graphic
Rendition
, Select image reproduction
2)
Csin [; k] m
N/K
Define the selected display control,
M
Table
SGR
Escape code
N/K
Definition:
0
Normal mode,
1
High Brightness,
2
Brightness,
3
Italic,
4
Single underline,
5
Slow,
6
Flash,
7
Foreground background inversion,
8
Foreground is set as background to make text invisible
For example, the Italic code is"
Csi3m
"
,
"
Csi3; 6 m
"Blinking in Italic
3)
Color Control Code:
Use double digits
[34] x
,
3
Table foreground,
4
Table background
0
Black,
1
Red,
2
Green,
3
Huang,
4
Blue,
5
Yanghong,
6
Qing,
7
White
For example, the red italic is
Csi31; 3 m
Set
ANSI
The escape code is sent to the terminal simulator to control the output of the terminal;
Use
Echo
(Or
Cat
) Send the escape code to the terminal;
Input
ANSI
Escape code:
CTRL-V
, Plus
ESC
, Which will be displayed as"
^ [
"
Eg:
Echo
^ [[41 m this is a test ^ [0 m
Previous
^ [[
Used for setting, the last one
^ [[
Used to restore to default,
Echo
If there are multiple escape codes, double quotation marks are required.
Csi33; 44 m
Hour:
Echo "^ [33; 44mabc ^ [0 m"
4)
Note:
The terminal simulator will process the control code as long as it encounters it.
Cat
Browsing scripts with escape codes also affects Terminal display.