Shell script output with color font __ Zecundi

Source: Internet
Author: User
Tags clear screen set background

Output Effect Format control:
\033[0m Turn off all properties
\033[1m Set High brightness
\03[4m Underline
\033[5m Flashing
\033[7M Reverse Display
\033[8m Hidden
\033[30m--\033[37m set foreground color
\033[40m--\033[47m Set background color

Format control for cursor position and so on:
\033[na cursor up N line
\03[NB cursor Move n line down
\033[NC cursor Right n row
\033[nd Cursor Left n line
\033[Y;XH Set Cursor Position
\033[2J Clear Screen
\033[k clears the contents from the cursor to the end of the line
\033[s Save Cursor position
\033[u Restore cursor Position
\033[?25l Hide Cursor

\33[?25h Display Cursor Collation:
Coded Color/action
0 Reset properties to default settings
1 set Bold
2 Set half brightness (simulate color of color display)
4 Set underline (simulate color of color display)
5 Setting Flicker
7 Setting the reverse image
22 Setting general Density
24 Off underline
25 off flashing
27 Turn off the reverse image
30 setting Black foreground
31 Setting the red foreground
32 Setting Green foreground
33 Setting Brown foreground
34 Setting Blue Foreground
35 Setting Purple foreground
36 Setting Cyan Foreground
37 Setting White foreground
38 underline on the default foreground color
39 Close the underline on the default foreground color
40 Setting black background
41 Setting Red background
42 Setting Green Background
43 Setting Brown background
44 Setting Blue background
45 Setting purple Background
46 Setting Cyan Background
47 Setting white background
49 Setting the default black background
Special effects can be superimposed, need to use ";" Separated, for example: Flashing + underline + white background + black word for \033[5;4;47;30m flashing + underline + white background + black word for \033[0m
Here's a little example

#!/bin/bash # #下面是字体输出颜色及终端格式控制 #字体色范围: 30-37 echo-e "\033[30m black word \033[0m" echo-e "\033[31m red word \033[0m" ECHO-E "\033[3 2m Green character \033[0m "echo-e" \033[33m yellow word \033[0m "echo-e" \033[34m blue word \033[0m "echo-e" \033[35m purple word \033[0m "echo-e" \033 [36m sky blue character \033[0m "echo-e" \033[37m white word \033[0m "#字背景颜色范围: 40-47 echo-e" \033[40;37m black background text \033[0m "ECHO-E" \033[41;30m Red Bottom Black character \033[0m "Echo-e" \033[42;34m Green bottom Blue word \033[0m "echo-e" \033[43;34m yellow bottom Blue word \033[0m "echo-e" \033[44;30m Blue bottom Black word \033[0m "echo -E "\033[45;30m purple bottom black word \033[0m" echo-e "\033[46;30m blue background black word \033[0m" echo-e "\033[47;34m white bottom Blue word \033[0m" #控制选项说明 #\033[0m closes the There are properties #\033[1m set high brightness #\033[4m underline echo-e "\033[4;31m underline red word \033[0m" #闪烁 echo-e "\033[5;34m red word in flashing \033[0m" #反影 echo-e "\03  3[8m hidden \033[0m "#\033[30m-\033[37m set foreground color #\033[40m-\033[47m set background color #\033[na cursor up n line #\033[nb cursor down n row echo-e" \033[4a cursor up 4 lines \033[0m "#\033[nc cursor right n line #\033[nd cursor left n row #\033[y;xh set cursor position #\033[2j clear screen #\033[k purge from cursor to end of line ECHO-E" \033[k clear cursor to end of line \033[0m "#\033[s saves the cursor position #\033[uRestore cursor position #\033[?25| hidden cursor #\033[?25h display cursor ECHO-E "\033[?25l hidden cursor \033[0m" ECHO-E "\033[?25h display cursor \033[0m" 

Related Article

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.