On most terminals (with the exception of Windows' cmd.exe, of course) it is possible to colorize output using the \033
ANSI escape sequence.
在大多数终端上(除了Windows的cmd)。当然,可以使用\033 ANSI转义序列对输出进行着色。
Now I'm looking for a list of all supported colors and options (like bright and blinking).
现在我正在寻找一个列表,其中包含了所有支持的颜色和选项(比如明亮和闪烁)。
As there are probably some differences between the terminals supporting them: I'm mainly interested in those sequences supported by xterm-compatible terminals.
由于支持它们的终端之间可能存在一些差异:我主要对xterm兼容终端支持的那些序列感兴趣。
5 个解决方案
#1
116
The ANSI escape sequences you're looking for are the Select Graphic Rendition subset. All of these have the form
您要查找的ANSI转义序列是Select Graphic Rendition子集。所有这些都有形式
\033[XXXm
where XXX
is a series of semicolon-separated parameters.
其中XXX是一系列分号分隔的参数。
To say, make text red, bold, and underlined (we'll discuss many other options below) in C you might write:
在C中,你可以这样写:
printf("\033[31;1;4mHello\033[0m");
In C++ you'd use
在c++中使用
std::cout<<"\033[31;1;4mHello\033[0m";
In Python3 you'd use
在Python3你使用
print("\033[31;1;4mHello\033[0m")
and in Bash you'd use
在Bash中使用
echo -e "\033[31;1;4mHello\033[0m"
where the first part makes the text red (31
), bold (1
), underlined (4
) and the last part clears all this (0
).
第一部分使文本为红色(31)、粗体(1)、下划线(4),最后一部分清除所有这些(0)。
As described in the table below, there are a large number of text properties you can set, such as boldness, font, underlining, &c. (Isn't it silly that * doesn't allow you to put proper tables in answers?)
如下表所示,您可以设置大量的文本属性,比如粗体、字体、下划线等等。(*不允许你在答案中放置合适的表格,这难道不傻吗?)
Font Effects
╔══════════╦════════════════════════════════╦═════════════════════════════════════════════════════════════════════════╗
║ Code ║ Effect ║ Note ║
╠══════════╬════════════════════════════════╬═════════════════════════════════════════════════════════════════════════╣
║ 0 ║ Reset / Normal ║ all attributes off ║
║ 1 ║ Bold or increased intensity ║ ║
║ 2 ║ Faint (decreased intensity) ║ Not widely supported. ║
║ 3 ║ Italic ║ Not widely supported. Sometimes treated as inverse. ║
║ 4 ║ Underline ║ ║
║ 5 ║ Slow Blink ║ less than 150 per minute ║
║ 6 ║ Rapid Blink ║ MS-DOS ANSI.SYS; 150+ per minute; not widely supported ║
║ 7 ║ [[reverse video]] ║ swap foreground and background colors ║
║ 8 ║ Conceal ║ Not widely supported. ║
║ 9 ║ Crossed-out ║ Characters legible, but marked for deletion. Not widely supported. ║
║ 10 ║ Primary(default) font ║ ║
║ 11–19 ║ Alternate font ║ Select alternate font `n-10` ║
║ 20 ║ Fraktur ║ hardly ever supported ║
║ 21 ║ Bold off or Double Underline ║ Bold off not widely supported; double underline hardly ever supported. ║
║ 22 ║ Normal color or intensity ║ Neither bold nor faint ║
║ 23 ║ Not italic, not Fraktur ║ ║
║ 24 ║ Underline off ║ Not singly or doubly underlined ║
║ 25 ║ Blink off ║ ║
║ 27 ║ Inverse off ║ ║
║ 28 ║ Reveal ║ conceal off ║
║ 29 ║ Not crossed out ║ ║
║ 30–37 ║ Set foreground color ║ See color table below ║
║ 38 ║ Set foreground color ║ Next arguments are `5;n` or `2;r;g;b`, see below ║
║ 39 ║ Default foreground color ║ implementation defined (according to standard) ║
║ 40–47 ║ Set background color ║ See color table below ║
║ 48 ║ Set background color ║ Next arguments are `5;n` or `2;r;g;b`, see below ║
║ 49 ║ Default background color ║ implementation defined (according to standard) ║
║ 51 ║ Framed ║ ║
║ 52 ║ Encircled ║ ║
║ 53 ║ Overlined ║ ║
║ 54 ║ Not framed or encircled ║ ║
║ 55 ║ Not overlined ║ ║
║ 60 ║ ideogram underline ║ hardly ever supported ║
║ 61 ║ ideogram double underline ║ hardly ever supported ║
║ 62 ║ ideogram overline ║ hardly ever supported ║
║ 63 ║ ideogram double overline ║ hardly ever supported ║
║ 64 ║ ideogram stress marking ║ hardly ever supported ║
║ 65 ║ ideogram attributes off ║ reset the effects of all of 60-64 ║
║ 90–97 ║ Set bright foreground color ║ aixterm (not in standard) ║
║ 100–107 ║ Set bright background color ║ aixterm (not in standard) ║
╚══════════╩════════════════════════════════╩═════════════════════════════════════════════════════════════════════════╝
2-bit Colours
You've got this already!
你已经得到了这个!
4-bit Colours
The standards implementing terminal colours began with limited (4-bit) options. The table below lists the RGB values of the background and foreground colours used for these by a variety of terminal emulators:
实现终端颜色的标准以有限的(4位)选项开始。下表列出了各种终端模拟器使用的背景和前景颜色的RGB值:
Using the above, you can make red text on a green background (but why?) using:
使用上述方法,您可以在绿色背景上创建红色文本(但为什么?)
\033[31;42m
11 Colours (An Interlude)
In their book "Basic Color Terms: Their Universality and Evolution", Brent Berlin and Paul Kay used data collected from twenty different languages from a range of language families to identify eleven possible basic color categories: white, black, red, green, yellow, blue, brown, purple, pink, orange, and gray.
布兰特·柏林和保罗·凯在他们的《基本颜色术语:它们的普遍性和进化》一书中,利用从不同语系的20种语言中收集的数据,确定了11种可能的基本颜色类别:白色、黑色、红色、绿色、黄色、棕色、紫色、粉色、橙色和灰色。
Berlin and Kay found that, in languages with fewer than the maximum eleven color categories, the colors followed a specific evolutionary pattern. This pattern is as follows:
柏林和凯发现,在少于11种颜色类别的语言中,颜色遵循一种特定的进化模式。这种模式如下:
- All languages contain terms for black (cool colours) and white (bright colours).
- 所有语言都包含黑色(冷色调)和白色(亮色调)的术语。
- If a language contains three terms, then it contains a term for red.
- 如果一种语言包含三个术语,那么它包含一个红色的术语。
- If a language contains four terms, then it contains a term for either green or yellow (but not both).
- 如果一种语言包含4个术语,那么它就包含一个绿色或黄色的术语(但不是两者都包含)。
- If a language contains five terms, then it contains terms for both green and yellow.
- 如果一种语言包含5个术语,那么它包含了绿色和黄色的术语。
- If a language contains six terms, then it contains a term for blue.
- 如果一种语言包含六个术语,那么它就包含一个表示蓝色的术语。
- If a language contains seven terms, then it contains a term for brown.
- 如果一种语言包含7个术语,那么它就包含brown这个术语。
- If a language contains eight or more terms, then it contains terms for purple, pink, orange or gray.
- 如果一门语言包含八个或更多的术语,那么它就包含了紫色、粉色、橙色或灰色的术语。
This may be why story Beowulf only contains the colours black, white, and red. It may also be why the Bible does not contain the colour blue. Homer's Odyssey contains black almost 200 times and white about 100 times. Red appears 15 times, while yellow and green appear only 10 times. (More information here)
这也许就是为什么《贝奥武夫的故事》中只有黑、白、红三种颜色。这也可能是为什么圣经中没有蓝色。荷马的《奥德赛》中黑色有200次,白色有100次。红色出现了15次,而黄色和绿色只出现了10次。(这里的更多信息)
Differences between languages are also interesting: note the profusion of distinct colour words used by English vs. Chinese. However, digging deeper into these languages shows that each uses colour in distinct ways. (More information)
语言之间的差异也很有趣:注意英语和汉语使用的大量不同颜色的词。然而,深入研究这些语言表明,每种语言都以不同的方式使用颜色。(更多信息)
Generally speaking, the naming, use, and grouping of colours in human languages is fascinating. Now, back to the show.
一般来说,人类语言中颜色的命名、使用和分组是很吸引人的。现在,回到节目。
8-bit (256) colours
Technology advanced, and tables of 256 pre-selected colours became available, as shown below.
技术进步了,256种预先选择的颜色的表格可以使用,如下所示。
Using these above, you can make pink text like so:
使用上面的这些,你可以做出粉红色的文字如下:
\033[38;5;206m #That is, \033[38;5;<FG COLOR>m
And make an early-morning blue background using
用清晨的蓝色背景
\033[48;5;57m #That is, \033[48;5;<BG COLOR>m
And, of course, you can combine these:
当然,你可以把这些结合起来
\033[38;5;206;48;5;57m
The 8-bit colours are arranged like so:
8位的颜色排列如下:
0x00-0x07: standard colors (same as the 4-bit colours)
0x08-0x0F: high intensity colors
0x10-0xE7: 6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5)
0xE8-0xFF: grayscale from black to white in 24 steps
ALL THE COLOURS
Now we are living in the future, and the full RGB spectrum is available using:
现在我们生活在未来,完整的RGB频谱可以使用:
\033[38;2;<r>;<g>;<b>m #Select RGB foreground color
\033[48;2;<r>;<g>;<b>m #Select RGB background color
So you can put pinkish text on a brownish background using
所以你可以把粉红色的文字放在棕色的背景上
\033[38;2;255;82;197;48;2;155;106;0mHello
Support for "true color" terminals is listed here.
这里列出了对“真实颜色”终端的支持。
Much of the above is drawn from the Wikipedia page "ANSI escape code".
上面的大部分内容来自*的“ANSI escape code”。
#3
10
How about:
如何:
ECMA-48 - Control Functions for Coded Character Sets, 5th edition (June 1991) - A standard defining the color control codes, that is apparently supported also by xterm.
ECMA-48 -编码字符集的控制函数,第5版(1991年6月)-一个定义颜色控制码的标准,显然也得到xterm的支持。
SGR 38 and 48 were originally reserved by ECMA-48, but were fleshed out a few years later in a joint ITU, IEC, and ISO standard, which comes in several parts and which (amongst a whole lot of other things) documents the SGR 38/48 control sequences for direct colour and indexed colour:
SGR 38和48最初是由ECMA-48保留,但却充实几年后在一份联合电联,IEC、ISO标准,分了几个部分,这(还有很多其他事情)文档SGR 38/48控制序列直接色彩和索引颜色:
- Information technology — Open Document Architecture (ODA) and interchange format: Document structures. T.412. International Telecommunication Union.
- 信息技术。开放式文档体系结构(ODA)和交换格式:文档结构。T.412。国际电信联盟。
- Information technology — Open Document Architecture (ODA) and interchange format: Character content architectures. T.416. International Telecommunication Union.
- 信息技术。开放文档体系结构(ODA)和交换格式:字符内容体系结构。T.416。国际电信联盟。
- Information technology— Open Document Architecture (ODA) and Interchange Format: Character content architectures. ISO/IEC 8613-6:1994. International Organization for Standardization.
- 信息技术。开放文档体系结构(ODA)和交换格式:字符内容体系结构。ISO / IEC 8613 - 6:1994。国际标准化组织。
There's a column for xterm in this table on the Wikipedia page for ANSI escape codes
在*页面上有一个关于xterm的列,用于ANSI转义代码
#4
7
There are some more interesting ones along with related info.
除了相关信息,还有一些更有趣的信息。
- http://wiki.bash-hackers.org/scripting/terminalcodes
- http://wiki.bash-hackers.org/scripting/terminalcodes
- http://www.termsys.demon.co.uk/vtansi.htm
- http://www.termsys.demon.co.uk/vtansi.htm
- http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
- http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
- http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/c327.html
- http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/c327.html
- https://wiki.archlinux.org/index.php/Color_Bash_Prompt
- https://wiki.archlinux.org/index.php/Color_Bash_Prompt
#5
2
It's related absolutely to your terminal. VTE doesn't support blink, If you use gnome-terminal
, tilda
, guake
, terminator
, xfce4-terminal
and so on accornding to VTE, You'll don't have blink.
If you use want to use blink on VTE, You have to use xterm
command.
You can use infocmp command with terminal name:
它绝对和你的终端有关。VTE不支持blink,如果你使用gnome-terminal, tilda, guake, terminator, xfce4-terminal等,你就不会有blink。如果要在VTE上使用blink,就必须使用xterm命令。您可以使用infocmp命令,其终端名称为:
#infocmp vt100
#infocmp xterm
#infocmp vte
For example :
例如:
# infocmp vte
# Reconstructed via infocmp from file: /usr/share/terminfo/v/vte
vte|VTE aka GNOME Terminal,
am, bce, mir, msgr, xenl,
colors#8, cols#80, it#8, lines#24, ncv#16, pairs#64,
acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
bel=^G, bold=\E[1m, civis=\E[?25l, clear=\E[H\E[2J,
cnorm=\E[?25h, cr=^M, csr=\E[%i%p1%d;%p2%dr,
cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=^J,
cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P,
dim=\E[2m, dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J,
el=\E[K, enacs=\E)0, home=\E[H, hpa=\E[%i%p1%dG, ht=^I,
hts=\EH, il=\E[%p1%dL, il1=\E[L, ind=^J, invis=\E[8m,
is2=\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8,
kDC=\E[3;2~, kEND=\E[1;2F, kHOM=\E[1;2H, kIC=\E[2;2~,
kLFT=\E[1;2D, kNXT=\E[6;2~, kPRV=\E[5;2~, kRIT=\E[1;2C,
kb2=\E[E, kbs=\177, kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB,
kcuf1=\EOC, kcuu1=\EOA, kdch1=\E[3~, kend=\EOF, kf1=\EOP,
kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[1;2P,
kf14=\E[1;2Q, kf15=\E[1;2R, kf16=\E[1;2S, kf17=\E[15;2~,
kf18=\E[17;2~, kf19=\E[18;2~, kf2=\EOQ, kf20=\E[19;2~,
kf21=\E[20;2~, kf22=\E[21;2~, kf23=\E[23;2~,
kf24=\E[24;2~, kf25=\E[1;5P, kf26=\E[1;5Q, kf27=\E[1;5R,
kf28=\E[1;5S, kf29=\E[15;5~, kf3=\EOR, kf30=\E[17;5~,
kf31=\E[18;5~, kf32=\E[19;5~, kf33=\E[20;5~,
kf34=\E[21;5~, kf35=\E[23;5~, kf36=\E[24;5~,
kf37=\E[1;6P, kf38=\E[1;6Q, kf39=\E[1;6R, kf4=\EOS,
kf40=\E[1;6S, kf41=\E[15;6~, kf42=\E[17;6~,
kf43=\E[18;6~, kf44=\E[19;6~, kf45=\E[20;6~,
kf46=\E[21;6~, kf47=\E[23;6~, kf48=\E[24;6~,
kf49=\E[1;3P, kf5=\E[15~, kf50=\E[1;3Q, kf51=\E[1;3R,
kf52=\E[1;3S, kf53=\E[15;3~, kf54=\E[17;3~,
kf55=\E[18;3~, kf56=\E[19;3~, kf57=\E[20;3~,
kf58=\E[21;3~, kf59=\E[23;3~, kf6=\E[17~, kf60=\E[24;3~,
kf61=\E[1;4P, kf62=\E[1;4Q, kf63=\E[1;4R, kf7=\E[18~,
kf8=\E[19~, kf9=\E[20~, kfnd=\E[1~, khome=\EOH,
kich1=\E[2~, kind=\E[1;2B, kmous=\E[M, knp=\E[6~,
kpp=\E[5~, kri=\E[1;2A, kslt=\E[4~, meml=\El, memu=\Em,
op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\EM, ritm=\E[23m,
rmacs=^O, rmam=\E[?7l, rmcup=\E[2J\E[?47l\E8, rmir=\E[4l,
rmkx=\E[?1l\E>, rmso=\E[m, rmul=\E[m, rs1=\Ec,
rs2=\E7\E[r\E8\E[m\E[?7h\E[!p\E[?1;3;4;6l\E[4l\E>\E[?1000l\E[?25h,
sc=\E7, setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p5%t;2%;%?%p7%t;8%;%?%p1%p3%|%t;7%;m%?%p9%t\016%e\017%;,
sgr0=\E[0m\017, sitm=\E[3m, smacs=^N, smam=\E[?7h,
smcup=\E7\E[?47h, smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m,
smul=\E[4m, tbc=\E[3g, u6=\E[%i%d;%dR, u7=\E[6n,
u8=\E[?%[;0123456789]c, u9=\E[c, vpa=\E[%i%p1%dd,
#1
116
The ANSI escape sequences you're looking for are the Select Graphic Rendition subset. All of these have the form
您要查找的ANSI转义序列是Select Graphic Rendition子集。所有这些都有形式
\033[XXXm
where XXX
is a series of semicolon-separated parameters.
其中XXX是一系列分号分隔的参数。
To say, make text red, bold, and underlined (we'll discuss many other options below) in C you might write:
在C中,你可以这样写:
printf("\033[31;1;4mHello\033[0m");
In C++ you'd use
在c++中使用
std::cout<<"\033[31;1;4mHello\033[0m";
In Python3 you'd use
在Python3你使用
print("\033[31;1;4mHello\033[0m")
and in Bash you'd use
在Bash中使用
echo -e "\033[31;1;4mHello\033[0m"
where the first part makes the text red (31
), bold (1
), underlined (4
) and the last part clears all this (0
).
第一部分使文本为红色(31)、粗体(1)、下划线(4),最后一部分清除所有这些(0)。
As described in the table below, there are a large number of text properties you can set, such as boldness, font, underlining, &c. (Isn't it silly that * doesn't allow you to put proper tables in answers?)
如下表所示,您可以设置大量的文本属性,比如粗体、字体、下划线等等。(*不允许你在答案中放置合适的表格,这难道不傻吗?)
Font Effects
╔══════════╦════════════════════════════════╦═════════════════════════════════════════════════════════════════════════╗
║ Code ║ Effect ║ Note ║
╠══════════╬════════════════════════════════╬═════════════════════════════════════════════════════════════════════════╣
║ 0 ║ Reset / Normal ║ all attributes off ║
║ 1 ║ Bold or increased intensity ║ ║
║ 2 ║ Faint (decreased intensity) ║ Not widely supported. ║
║ 3 ║ Italic ║ Not widely supported. Sometimes treated as inverse. ║
║ 4 ║ Underline ║ ║
║ 5 ║ Slow Blink ║ less than 150 per minute ║
║ 6 ║ Rapid Blink ║ MS-DOS ANSI.SYS; 150+ per minute; not widely supported ║
║ 7 ║ [[reverse video]] ║ swap foreground and background colors ║
║ 8 ║ Conceal ║ Not widely supported. ║
║ 9 ║ Crossed-out ║ Characters legible, but marked for deletion. Not widely supported. ║
║ 10 ║ Primary(default) font ║ ║
║ 11–19 ║ Alternate font ║ Select alternate font `n-10` ║
║ 20 ║ Fraktur ║ hardly ever supported ║
║ 21 ║ Bold off or Double Underline ║ Bold off not widely supported; double underline hardly ever supported. ║
║ 22 ║ Normal color or intensity ║ Neither bold nor faint ║
║ 23 ║ Not italic, not Fraktur ║ ║
║ 24 ║ Underline off ║ Not singly or doubly underlined ║
║ 25 ║ Blink off ║ ║
║ 27 ║ Inverse off ║ ║
║ 28 ║ Reveal ║ conceal off ║
║ 29 ║ Not crossed out ║ ║
║ 30–37 ║ Set foreground color ║ See color table below ║
║ 38 ║ Set foreground color ║ Next arguments are `5;n` or `2;r;g;b`, see below ║
║ 39 ║ Default foreground color ║ implementation defined (according to standard) ║
║ 40–47 ║ Set background color ║ See color table below ║
║ 48 ║ Set background color ║ Next arguments are `5;n` or `2;r;g;b`, see below ║
║ 49 ║ Default background color ║ implementation defined (according to standard) ║
║ 51 ║ Framed ║ ║
║ 52 ║ Encircled ║ ║
║ 53 ║ Overlined ║ ║
║ 54 ║ Not framed or encircled ║ ║
║ 55 ║ Not overlined ║ ║
║ 60 ║ ideogram underline ║ hardly ever supported ║
║ 61 ║ ideogram double underline ║ hardly ever supported ║
║ 62 ║ ideogram overline ║ hardly ever supported ║
║ 63 ║ ideogram double overline ║ hardly ever supported ║
║ 64 ║ ideogram stress marking ║ hardly ever supported ║
║ 65 ║ ideogram attributes off ║ reset the effects of all of 60-64 ║
║ 90–97 ║ Set bright foreground color ║ aixterm (not in standard) ║
║ 100–107 ║ Set bright background color ║ aixterm (not in standard) ║
╚══════════╩════════════════════════════════╩═════════════════════════════════════════════════════════════════════════╝
2-bit Colours
You've got this already!
你已经得到了这个!
4-bit Colours
The standards implementing terminal colours began with limited (4-bit) options. The table below lists the RGB values of the background and foreground colours used for these by a variety of terminal emulators:
实现终端颜色的标准以有限的(4位)选项开始。下表列出了各种终端模拟器使用的背景和前景颜色的RGB值:
Using the above, you can make red text on a green background (but why?) using:
使用上述方法,您可以在绿色背景上创建红色文本(但为什么?)
\033[31;42m
11 Colours (An Interlude)
In their book "Basic Color Terms: Their Universality and Evolution", Brent Berlin and Paul Kay used data collected from twenty different languages from a range of language families to identify eleven possible basic color categories: white, black, red, green, yellow, blue, brown, purple, pink, orange, and gray.
布兰特·柏林和保罗·凯在他们的《基本颜色术语:它们的普遍性和进化》一书中,利用从不同语系的20种语言中收集的数据,确定了11种可能的基本颜色类别:白色、黑色、红色、绿色、黄色、棕色、紫色、粉色、橙色和灰色。
Berlin and Kay found that, in languages with fewer than the maximum eleven color categories, the colors followed a specific evolutionary pattern. This pattern is as follows:
柏林和凯发现,在少于11种颜色类别的语言中,颜色遵循一种特定的进化模式。这种模式如下:
- All languages contain terms for black (cool colours) and white (bright colours).
- 所有语言都包含黑色(冷色调)和白色(亮色调)的术语。
- If a language contains three terms, then it contains a term for red.
- 如果一种语言包含三个术语,那么它包含一个红色的术语。
- If a language contains four terms, then it contains a term for either green or yellow (but not both).
- 如果一种语言包含4个术语,那么它就包含一个绿色或黄色的术语(但不是两者都包含)。
- If a language contains five terms, then it contains terms for both green and yellow.
- 如果一种语言包含5个术语,那么它包含了绿色和黄色的术语。
- If a language contains six terms, then it contains a term for blue.
- 如果一种语言包含六个术语,那么它就包含一个表示蓝色的术语。
- If a language contains seven terms, then it contains a term for brown.
- 如果一种语言包含7个术语,那么它就包含brown这个术语。
- If a language contains eight or more terms, then it contains terms for purple, pink, orange or gray.
- 如果一门语言包含八个或更多的术语,那么它就包含了紫色、粉色、橙色或灰色的术语。
This may be why story Beowulf only contains the colours black, white, and red. It may also be why the Bible does not contain the colour blue. Homer's Odyssey contains black almost 200 times and white about 100 times. Red appears 15 times, while yellow and green appear only 10 times. (More information here)
这也许就是为什么《贝奥武夫的故事》中只有黑、白、红三种颜色。这也可能是为什么圣经中没有蓝色。荷马的《奥德赛》中黑色有200次,白色有100次。红色出现了15次,而黄色和绿色只出现了10次。(这里的更多信息)
Differences between languages are also interesting: note the profusion of distinct colour words used by English vs. Chinese. However, digging deeper into these languages shows that each uses colour in distinct ways. (More information)
语言之间的差异也很有趣:注意英语和汉语使用的大量不同颜色的词。然而,深入研究这些语言表明,每种语言都以不同的方式使用颜色。(更多信息)
Generally speaking, the naming, use, and grouping of colours in human languages is fascinating. Now, back to the show.
一般来说,人类语言中颜色的命名、使用和分组是很吸引人的。现在,回到节目。
8-bit (256) colours
Technology advanced, and tables of 256 pre-selected colours became available, as shown below.
技术进步了,256种预先选择的颜色的表格可以使用,如下所示。
Using these above, you can make pink text like so:
使用上面的这些,你可以做出粉红色的文字如下:
\033[38;5;206m #That is, \033[38;5;<FG COLOR>m
And make an early-morning blue background using
用清晨的蓝色背景
\033[48;5;57m #That is, \033[48;5;<BG COLOR>m
And, of course, you can combine these:
当然,你可以把这些结合起来
\033[38;5;206;48;5;57m
The 8-bit colours are arranged like so:
8位的颜色排列如下:
0x00-0x07: standard colors (same as the 4-bit colours)
0x08-0x0F: high intensity colors
0x10-0xE7: 6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5)
0xE8-0xFF: grayscale from black to white in 24 steps
ALL THE COLOURS
Now we are living in the future, and the full RGB spectrum is available using:
现在我们生活在未来,完整的RGB频谱可以使用:
\033[38;2;<r>;<g>;<b>m #Select RGB foreground color
\033[48;2;<r>;<g>;<b>m #Select RGB background color
So you can put pinkish text on a brownish background using
所以你可以把粉红色的文字放在棕色的背景上
\033[38;2;255;82;197;48;2;155;106;0mHello
Support for "true color" terminals is listed here.
这里列出了对“真实颜色”终端的支持。
Much of the above is drawn from the Wikipedia page "ANSI escape code".
上面的大部分内容来自*的“ANSI escape code”。
#2
#3
10
How about:
如何:
ECMA-48 - Control Functions for Coded Character Sets, 5th edition (June 1991) - A standard defining the color control codes, that is apparently supported also by xterm.
ECMA-48 -编码字符集的控制函数,第5版(1991年6月)-一个定义颜色控制码的标准,显然也得到xterm的支持。
SGR 38 and 48 were originally reserved by ECMA-48, but were fleshed out a few years later in a joint ITU, IEC, and ISO standard, which comes in several parts and which (amongst a whole lot of other things) documents the SGR 38/48 control sequences for direct colour and indexed colour:
SGR 38和48最初是由ECMA-48保留,但却充实几年后在一份联合电联,IEC、ISO标准,分了几个部分,这(还有很多其他事情)文档SGR 38/48控制序列直接色彩和索引颜色:
- Information technology — Open Document Architecture (ODA) and interchange format: Document structures. T.412. International Telecommunication Union.
- 信息技术。开放式文档体系结构(ODA)和交换格式:文档结构。T.412。国际电信联盟。
- Information technology — Open Document Architecture (ODA) and interchange format: Character content architectures. T.416. International Telecommunication Union.
- 信息技术。开放文档体系结构(ODA)和交换格式:字符内容体系结构。T.416。国际电信联盟。
- Information technology— Open Document Architecture (ODA) and Interchange Format: Character content architectures. ISO/IEC 8613-6:1994. International Organization for Standardization.
- 信息技术。开放文档体系结构(ODA)和交换格式:字符内容体系结构。ISO / IEC 8613 - 6:1994。国际标准化组织。
There's a column for xterm in this table on the Wikipedia page for ANSI escape codes
在*页面上有一个关于xterm的列,用于ANSI转义代码
#4
7
There are some more interesting ones along with related info.
除了相关信息,还有一些更有趣的信息。
- http://wiki.bash-hackers.org/scripting/terminalcodes
- http://wiki.bash-hackers.org/scripting/terminalcodes
- http://www.termsys.demon.co.uk/vtansi.htm
- http://www.termsys.demon.co.uk/vtansi.htm
- http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
- http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
- http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/c327.html
- http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/c327.html
- https://wiki.archlinux.org/index.php/Color_Bash_Prompt
- https://wiki.archlinux.org/index.php/Color_Bash_Prompt
#5
2
It's related absolutely to your terminal. VTE doesn't support blink, If you use gnome-terminal
, tilda
, guake
, terminator
, xfce4-terminal
and so on accornding to VTE, You'll don't have blink.
If you use want to use blink on VTE, You have to use xterm
command.
You can use infocmp command with terminal name:
它绝对和你的终端有关。VTE不支持blink,如果你使用gnome-terminal, tilda, guake, terminator, xfce4-terminal等,你就不会有blink。如果要在VTE上使用blink,就必须使用xterm命令。您可以使用infocmp命令,其终端名称为:
#infocmp vt100
#infocmp xterm
#infocmp vte
For example :
例如:
# infocmp vte
# Reconstructed via infocmp from file: /usr/share/terminfo/v/vte
vte|VTE aka GNOME Terminal,
am, bce, mir, msgr, xenl,
colors#8, cols#80, it#8, lines#24, ncv#16, pairs#64,
acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
bel=^G, bold=\E[1m, civis=\E[?25l, clear=\E[H\E[2J,
cnorm=\E[?25h, cr=^M, csr=\E[%i%p1%d;%p2%dr,
cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=^J,
cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P,
dim=\E[2m, dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J,
el=\E[K, enacs=\E)0, home=\E[H, hpa=\E[%i%p1%dG, ht=^I,
hts=\EH, il=\E[%p1%dL, il1=\E[L, ind=^J, invis=\E[8m,
is2=\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8,
kDC=\E[3;2~, kEND=\E[1;2F, kHOM=\E[1;2H, kIC=\E[2;2~,
kLFT=\E[1;2D, kNXT=\E[6;2~, kPRV=\E[5;2~, kRIT=\E[1;2C,
kb2=\E[E, kbs=\177, kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB,
kcuf1=\EOC, kcuu1=\EOA, kdch1=\E[3~, kend=\EOF, kf1=\EOP,
kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[1;2P,
kf14=\E[1;2Q, kf15=\E[1;2R, kf16=\E[1;2S, kf17=\E[15;2~,
kf18=\E[17;2~, kf19=\E[18;2~, kf2=\EOQ, kf20=\E[19;2~,
kf21=\E[20;2~, kf22=\E[21;2~, kf23=\E[23;2~,
kf24=\E[24;2~, kf25=\E[1;5P, kf26=\E[1;5Q, kf27=\E[1;5R,
kf28=\E[1;5S, kf29=\E[15;5~, kf3=\EOR, kf30=\E[17;5~,
kf31=\E[18;5~, kf32=\E[19;5~, kf33=\E[20;5~,
kf34=\E[21;5~, kf35=\E[23;5~, kf36=\E[24;5~,
kf37=\E[1;6P, kf38=\E[1;6Q, kf39=\E[1;6R, kf4=\EOS,
kf40=\E[1;6S, kf41=\E[15;6~, kf42=\E[17;6~,
kf43=\E[18;6~, kf44=\E[19;6~, kf45=\E[20;6~,
kf46=\E[21;6~, kf47=\E[23;6~, kf48=\E[24;6~,
kf49=\E[1;3P, kf5=\E[15~, kf50=\E[1;3Q, kf51=\E[1;3R,
kf52=\E[1;3S, kf53=\E[15;3~, kf54=\E[17;3~,
kf55=\E[18;3~, kf56=\E[19;3~, kf57=\E[20;3~,
kf58=\E[21;3~, kf59=\E[23;3~, kf6=\E[17~, kf60=\E[24;3~,
kf61=\E[1;4P, kf62=\E[1;4Q, kf63=\E[1;4R, kf7=\E[18~,
kf8=\E[19~, kf9=\E[20~, kfnd=\E[1~, khome=\EOH,
kich1=\E[2~, kind=\E[1;2B, kmous=\E[M, knp=\E[6~,
kpp=\E[5~, kri=\E[1;2A, kslt=\E[4~, meml=\El, memu=\Em,
op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\EM, ritm=\E[23m,
rmacs=^O, rmam=\E[?7l, rmcup=\E[2J\E[?47l\E8, rmir=\E[4l,
rmkx=\E[?1l\E>, rmso=\E[m, rmul=\E[m, rs1=\Ec,
rs2=\E7\E[r\E8\E[m\E[?7h\E[!p\E[?1;3;4;6l\E[4l\E>\E[?1000l\E[?25h,
sc=\E7, setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p5%t;2%;%?%p7%t;8%;%?%p1%p3%|%t;7%;m%?%p9%t\016%e\017%;,
sgr0=\E[0m\017, sitm=\E[3m, smacs=^N, smam=\E[?7h,
smcup=\E7\E[?47h, smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m,
smul=\E[4m, tbc=\E[3g, u6=\E[%i%d;%dR, u7=\E[6n,
u8=\E[?%[;0123456789]c, u9=\E[c, vpa=\E[%i%p1%dd,