stty的用法及解析--escape sequence code的用法
来源:互联网 发布:印刷报价小秘书软件 编辑:程序博客网 时间:2024/05/19 15:22
在linux console显示各种颜色的信息可以使用特殊的符号串:escape sequence code.通过使用escape sequence code可以在linux终端以高亮,粗体,闪烁、多种颜色等方式展示消息
下面以实例说明:
在终端打印hello world
如果加上escape sequence code就可以调整打印在终端上的消息属性:
\033[34m 就是 escape sequence code
\033[34m Hello Colorful World\!整个字符串的处理过程为:
1.读到 \033,说明后面的字符是ANSI escape sequence,会特殊处理
2.使用 [34m 来设定终端的前景色为蓝色
3.打印 Hello Colorful World\! ,颜色为蓝色
\033[ 实际上在输入的文本信息中作为一个特殊标识,终端读到 \033 字符的时候,识别出这是一个escape character;将切换到escape模式。然后读取“[” 字符移入到CSI模式(Command Sequence Introduction (CSI) mode),在CSI模式下,终端读取这些ASCII码用分号“;”隔开,直到读入一个完整的动作指令。上面打印Hello Colorful World!的例子里面
\033 作为escape character, 通知终端切换到escape模式;
[ CSI的开始;
34 读入的参数;
m 制定将要执行的动作
在shell脚本中可能会使用到一些常用的动作及属性,表格表示如下:
2Faint (decreased intensity)not widely supported3Italic: onnot widely supported. Sometimes treated as inverse.4Underline: Single
5Blink: Slowless than 150 per minute6Blink: RapidMS-DOS ANSI.SYS; 150 per minute or more; not widely supported7Image: Negativeinverse or reverse; swap foreground and background8Concealnot widely supported9Crossed-outCharacters legible, but marked for deletion. Not widely supported.10Primary(default) font
11–19n-th alternate fontSelect the n-th alternate font. 14 being the fourth alternate font, up to 19 being the 9th alternate font.20Frakturhardly ever supported21Bright/Bold: off or Underline: Doublebold off not widely supported, double underline hardly ever22Normal color or intensityneither bright, bold nor faint23Not italic, not Fraktur
24Underline: Nonenot singly or doubly underlined25Blink: off
26Reserved
27Image: Positive
28Revealconceal off29Not crossed out
30–37Set text color30 + x, where x is from the color table below38Set xterm-256 text color[dubious ]next arguments are 5;x where x is color index (0..255)39Default text colorimplementation defined (according to standard)40–47Set background color40 + x, where x is from the color table below48Set xterm-256 background colornext arguments are 5;x where x is color index (0..255)49Default background colorimplementation defined (according to standard)50Reserved
51Framed
52Encircled
53Overlined
54Not framed or encircled
55Not overlined
56–59Reserved
60ideogram underline or right side linehardly ever supported61ideogram double underline or double line on the right sidehardly ever supported62ideogram overline or left side linehardly ever supported63ideogram double overline or double line on the left sidehardly ever supported64ideogram stress markinghardly ever supported90–99Set foreground color, high intensityaixterm (not in standard)100–109Set background color, high intensityaixterm (not in standard)常用颜色设置如下:
参考:
1.http://www.cnblogs.com/shipfi/articles/375430.html
2.http://en.wikipedia.org/wiki/ANSI_escape_code#Windows_and_DOS
- stty的用法及解析--escape sequence code的用法
- stty命令的用法全解
- SQL中的escape的用法
- Oracle SQL 部分特殊字符转义及escape的用法
- Oracle SQL 部分特殊字符转义及escape的用法
- sequence 的用法
- oracle的sequence用法
- sequence的用法
- oracle sequence的用法
- ORACLE SEQUENCE 的用法
- stty用法大全
- verilog中escape identifer 的用法
- js中的escape的用法汇总
- js中的escape的用法汇总
- js中的escape的用法汇总
- js中的escape的用法汇总
- escape()、encodeURI()、encodeURIComponent()的区别和用法
- C51的code用法
- Android多媒体真烦人
- Qt 笔记 Chapter6-Chapter8
- QT开发日记
- HDFS写入和读取流程
- Spring Quartz定时详情
- stty的用法及解析--escape sequence code的用法
- method area constant pool
- rich:dataTable+a4j:commandLink,ajax删除行(seam)
- Oracle笔记
- 腾讯QQ空间率先通过W3C认证
- OracleTuning笔记
- XStream简单介绍
- Java中的容器类
- QImage 和 IplImage 之间转换问题