shell output colored fonts

SecureCRT settings

Output font color effect on the command line. WIndows the cmd is not supported, you can use Git Bash default.
And SecureCRT, the effect is not turned on by default, need to modify the answer settings:
shell output colored fonts

The default settings can also have the effect, but does not support color.
Check the ANSI color options, you can color the results, several other hook can try the effect is to set the color of the other aspects.

Effects format

Output format control effects:

symbol Explanation
\033[0m Close all properties
\ 033 [1m Set high brightness
\ 03 [4m Underline
\033[5m flicker
\ 033 [7m Anti-significant
\ 033 [8m Blanking
\ 033 [30m ~ \ 033 [37m Set the foreground color
\033[40m ~ \033[47m Set the background color

Format control the cursor position or the like:

symbol Explanation
\ 033 [nA Move the cursor row n
\03[nB Cursor down the line n
\033[nC Cursor right row n
\033[nD Cursor left row n
\033[y;xH Set the cursor position
\ 033 [2J Clear screen
\033[K Clear the contents from the cursor to the end of the line
\033[s Save Cursor Position
\ 033 [in Restore cursor position
\ 033 [? 25l Hide the cursor
\33[?25h Display cursor

Color coding

coding:

  • 0: Reset property to default settings
  • 1: Set Bold
  • 2: set to half the brightness (color analog color display)
  • 4: Set underscore (simulated color a color display)
  • 5: setting flashes
  • 7: Set-inverted images
  • 22: Set General density
  • 24: Close underscore
  • 25: Off Flashing
  • 27: Close-inverted images
  • 30: Set a black foreground
  • 31: Setting the prospect red
  • 32: Set green outlook
  • 33: Set brown Prospects
  • 34: Set blue prospects
  • 35: Setting purple prospects
  • 36: Settings Cyan prospects
  • 37: Setting the white foreground
  • 38: Setting underlines the default foreground color
  • 39: Close underlines the default foreground color
  • 40: Setting a black background
  • 41: Set red background
  • 42: Setting a green background
  • 43: Set brown background
  • 44: Setting a blue background
  • 45: Setting purple background
  • 46: Set a cyan background
  • 47: Set white background
  • 49: Set the default black background

The above effects can be superimposed, it requires a semicolon (;) spaced apart, for example:
blinking underline + + + White background is black, \ 033 [5; 4; 47; 30m words cool effect \ 033 [0m

Sample effects

Here is a small example

#!/bin/bash
#
#下面是字体输出颜色及终端格式控制
#字体色范围:30-37
echo -e "\033[30m 黑色字 \033[0m"
echo -e "\033[31m 红色字 \033[0m"
echo -e "\033[32m 绿色字 \033[0m"
echo -e "\033[33m ×××字 \033[0m"
echo -e "\033[34m 蓝色字 \033[0m"
echo -e "\033[35m 紫色字 \033[0m"
echo -e "\033[36m 天蓝字 \033[0m"
echo -e "\033[37m 白色字 \033[0m"
#字背景颜色范围:40-47
echo -e "\033[40;37m 黑底白字 \033[0m"
echo -e "\033[41;30m 红底黑字 \033[0m"
echo -e "\033[42;34m 绿底蓝字 \033[0m"
echo -e "\033[43;34m 黄底蓝字 \033[0m"
echo -e "\033[44;30m 蓝底黑字 \033[0m"
echo -e "\033[45;30m 紫底黑字 \033[0m"
echo -e "\033[46;30m 天蓝底黑字 \033[0m"
echo -e "\033[47;34m 白底蓝字 \033[0m"

#控制选项说明
#\033[0m 关闭所有属性
#\033[1m 设置高亮度
#\033[4m 下划线
echo -e "\033[4;31m 下划线红字 \033[0m"
#闪烁
echo -e "\033[5;34m 红字在闪烁 \033[0m"
#反影
echo -e "\033[8m 消隐 \033[0m "

#\033[30m-\033[37m 设置前景色
#\033[40m-\033[47m 设置背景色
#\033[nA光标上移n行
#\033[nB光标下移n行
echo -e "\033[4A 光标上移4行 \033[0m"
#\033[nC光标右移n行
#\033[nD光标左移n行
#\033[y;xH设置光标位置
#\033[2J清屏
#\033[K清除从光标到行尾的内容
echo -e "\033[K 清除光标到行尾的内容 \033[0m"
#\033[s 保存光标位置
#\033[u 恢复光标位置
#\033[?25| 隐藏光标
#\033[?25h 显示光标
echo -e "\033[?25l 隐藏光标 \033[0m"
echo -e "\033[?25h 显示光标 \033[0m"

Guess you like

Origin blog.51cto.com/steed/2422760