Using ANSI escape codes to color:
Black 0;30 Dark Gray 1;30
Red 0;31 Light Red 1;31
Green 0;32 Light Green 1;32
Brown/Orange 0;33 Yellow 1;33
Blue 0;34 Light Blue 1;34
Purple 0;35 Light Purple 1;35
Cyan 0;36 Light Cyan 1;36
Light Gray 0;37 White 1;37
No Color 0
#!/bin/bash
$ Red='\033[0;35m'
$ End='\033[0m' #No Color.
$ echo -e "${Red}This is a Test of Red Color Characters.${End}"
This is a Test of Red Color Characters.
#for general using, write them as functions
# Colors {{{
end="\033[0m"
red="\033[0;31m"
redb="\033[1;31m"
green="\033[0;32m"
yellow="\033[0;33m"
function red {
echo -e "${red}${1}${end}"
}
function redb {
echo -e "${redb}${1}${end}"
}
function green {
echo -e "${green}${1}${end}"
}
function yellow {
echo -e "${yellow}${1}${end}"
}
# }}}
redb "this is a test of color characters"
#> this is a test of color characters
$ uname -a # Show all OS info
Linux flax 4.15.0-101-generic #102-Ubuntu SMP Mon May 11 10:07:26 UTC
2020 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic
$ man ascii
NAME
ascii - ASCII character set encoded in octal, decimal, and hexadecimal
The following table contains the 128 ASCII characters.
Tables
For convenience, below are more compact tables in hex and decimal.
2 3 4 5 6 7 30 40 50 60 70 80 90 100 110 120
------------- ---------------------------------
0: 0 @ P ` p 0: ( 2 < F P Z d n x
1: ! 1 A Q a q 1: ) 3 = G Q [ e o y
2: " 2 B R b r 2: * 4 > H R \ f p z
3: # 3 C S c s 3: ! + 5 ? I S ] g q {
4: $ 4 D T d t 4: " , 6 @ J T ^ h r |
5: % 5 E U e u 5: # - 7 A K U _ i s }
6: & 6 F V f v 6: $ . 8 B L V ` j t ~
7: ' 7 G W g w 7: % / 9 C M W a k u DEL
8: ( 8 H X h x 8: & 0 : D N X b l v
9: ) 9 I Y i y 9: ' 1 ; E O Y c m w
A: * : J Z j z
B: + ; K [ k {
C: , < L \ l |
D: - = M ] m }
E: . > N ^ n ~
F: / ? O _ o DEL
没有评论:
发表评论