Shell (6) color.doc

Source: Internet
Author: User

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.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.