1 # https://en.wikipedia.org/wiki/ANSI_escape_code
2 # https://coolors.co/aa4465-ec7632-dcd5a0-f9cb40-875f00-698c6e-0b3820-5fafff-2f5d9d-7f5e97
4 # Sets shell environment variables to code for ANSI colors.
10 export UNDERLINE='\e[4m'
11 export STRIKETHROUGH='\e[9m'
15 export BROWN='\e[38;2;135;95;0m' #875F00
16 export BRIGHT_RED='\e[38;2;175;0;0m'
17 export LIGHT_RED='\e[38;2;170;68;101m' #AA4465
19 export DARK_RED='\e[38;5;52m'
20 export PINK='\e[38;2;231;90;124m' #E75A7C
21 export ORANGE='\e[38;2;236;118;50m' #EC7632
22 export YELLOW='\e[38;2;249;203;64m' #F9CB40
23 export GOLD='\e[38;5;94m'
24 export GREEN='\e[38;2;105;140;110m' #698C6E
25 export DARK_GREEN='\e[38;2;10;51;29m' #0A331D
26 export TEAL='\e[38;5;45m'
27 export CYAN='\e[38;2;95;175;255m' #5FAFFF
28 export BLUE='\e[38;2;47;93;157m' #2F5D9D
29 export DARK_BLUE='\e[38;5;18m'
30 export MAGENTA='\e[38;2;170;68;101m' #AA4465
31 export DARK_MAGENTA='\e[38;5;63m'
32 export PURPLE='\e[38;2;127;94;151m' #7F5E97
33 export ON_PURPLE='\e[48;2;127;94;151m' #7F5E97
34 export DARK_PURPLE='\e[38;5;56m'
36 export LIGHT_GRAY='\e[38;2;25;25;25m'
37 export LGRAY='\e[38;2;25;25;25m'
40 # 8-bit: As 256-color lookup tables became common on graphic cards,
41 # escape sequences were added to select from a pre-defined set of 256
44 # ESC[ 38;5;⟨n⟩ m Select foreground color
45 # ESC[ 48;5;⟨n⟩ m Select background color
46 # 0- 7: standard colors (as in ESC [ 30–37 m)
47 # 8- 15: high intensity colors (as in ESC [ 90–97 m)
48 # 16-231: 6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5)
49 # 232-255: grayscale from black to white in 24 steps
50 function make_fg_color() {
52 if [ "$1" -gt "5" ] || [ "$2" -gt "5" ] || [ "$3" -gt "5" ]; then
53 echo -ne "\e[38;2;$1;$2;$3m"
55 N=$(( 16 + 36 * $1 + 6 * $2 + $3 ))
56 echo -ne "\e[38;5;${N}m"
58 elif [ $# -eq 2 ]; then
59 N=$(( 16 + 36 * 0 + 6 * $1 + $2 ))
60 echo -ne "\e[38;5;${N}m"
61 elif [ $# -eq 1 ]; then
62 echo -ne "\e[38;5;$1m"
64 echo -ne ${LIGHT_GRAY}
68 function make_bg_color() {
70 if [ "$1" -gt "5" ] || [ "$2" -gt "5" ] || [ "$3" -gt "5" ]; then
71 echo -ne "\e[48;2;$1;$2;$3m"
73 N=$(( 16 + 36 * $1 + 6 * $2 + $3 ))
74 echo -ne "\e[48;5;${N}m"
76 elif [ $# -eq 2 ]; then
77 N=$(( 16 + 36 * 0 + 6 * $1 + $2 ))
78 echo -ne "\e[48;5;${N}m"
79 elif [ $# -eq 1 ]; then
80 echo -ne "\e[48;5;$1m"
87 export ON_BLACK='\e[40m'
88 export ON_LGRAY='\e[48;2;25;25;25m'
89 export ON_RED='\e[41m'
90 export ON_ORANGE='\e[48;2;236;118;50m'
91 export ON_GREEN='\e[48;2;105;140;110m'
92 export ON_YELLOW='\e[48;2;249;203;64m'
93 export ON_BLUE='\e[48;2;47;93;157m'
94 export ON_MAGENTA='\e[48;2;170;68;101m'
95 export ON_CYAN='\e[48;2;95;175;255m'
96 export ON_WHITE='\e[47m'
97 export ON_DARK_PURPLE='\e[48;5;56m'
100 export CURSOR='\e[38;5;208m' # ORANGY
101 export ON_CURSOR='\e[48;5;208m'
104 export NC="\e[0m" # color reset