\033[XXXm
is Select Graphic Rendition subset of ANSI
escape sequences, \033
is actually ESC character in ascii
octal format, \e
is equivalent in zsh shell, however, don’t
use \e
, \e
is not recognised in
awk
nor python
.
> echo "\033[31mRed Text\033[0m"
Red Text
> echo "\e[31mRed Text\e[0m"
Red Text
\033[
- Begin the color modificationsCODEm
- CODE + m
at the end\e[0m
- End the color modificationscode | description |
---|---|
30, 90 |
fg black |
31, 91 |
fg red |
32, 92 |
fg green |
33, 93 |
fg brown |
34, 94 |
fg blue |
35, 95 |
fg purple |
36, 96 |
fg cyan |
37, 96 |
fg light grey |
40 |
bg black |
41 |
bg red |
42 |
bg green |
43 |
bg brown |
44 |
bg blue |
45 |
bg purple |
46 |
bg cyan |
47 |
bg light grey |
0 |
reset / normal |
1 |
bold |
3 |
italic |
4 |
underline |
> for i in {1..111}
do
echo '\\e['$i'm' "\e[${i}mtext\e[0m"
done | column
See also: a comprehensive explanation