-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash_colors
393 lines (355 loc) ยท 9.9 KB
/
bash_colors
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# Reset
Color_Off="\e[0m" # Text Reset
# Regular Colors
Black="\e[0;30m" # Black
Red="\e[0;31m" # Red
Green="\e[0;32m" # Green
Yellow="\e[0;33m" # Yellow
Blue="\e[0;34m" # Blue
Purple="\e[0;35m" # Purple
Cyan="\e[0;36m" # Cyan
White="\e[0;37m" # White
# Bold
BBlack="\e[1;30m" # Black
BRed="\e[1;31m" # Red
BGreen="\e[1;32m" # Green
BYellow="\e[1;33m" # Yellow
BBlue="\e[1;34m" # Blue
BPurple="\e[1;35m" # Purple
BCyan="\e[1;36m" # Cyan
BWhite="\e[1;37m" # White
# Underline
UBlack="\e[4;30m" # Black
URed="\e[4;31m" # Red
UGreen="\e[4;32m" # Green
UYellow="\e[4;33m" # Yellow
UBlue="\e[4;34m" # Blue
UPurple="\e[4;35m" # Purple
UCyan="\e[4;36m" # Cyan
UWhite="\e[4;37m" # White
# Background
On_Black="\e[40m" # Black
On_Red="\e[41m" # Red
On_Green="\e[42m" # Green
On_Yellow="\e[43m" # Yellow
On_Blue="\e[44m" # Blue
On_Purple="\e[45m" # Purple
On_Cyan="\e[46m" # Cyan
On_White="\e[47m" # White
# High Intensity
IBlack="\e[0;90m" # Black
IRed="\e[0;91m" # Red
IGreen="\e[0;92m" # Green
IYellow="\e[0;93m" # Yellow
IBlue="\e[0;94m" # Blue
IPurple="\e[0;95m" # Purple
ICyan="\e[0;96m" # Cyan
IWhite="\e[0;97m" # White
# Bold High Intensity
BIBlack="\e[1;90m" # Black
BIRed="\e[1;91m" # Red
BIGreen="\e[1;92m" # Green
BIYellow="\e[1;93m" # Yellow
BIBlue="\e[1;94m" # Blue
BIPurple="\e[1;95m" # Purple
BICyan="\e[1;96m" # Cyan
BIWhite="\e[1;97m" # White
# High Intensity backgrounds
On_IBlack="\e[0;100m" # Black
On_IRed="\e[0;101m" # Red
On_IGreen="\e[0;102m" # Green
On_IYellow="\e[0;103m" # Yellow
On_IBlue="\e[0;104m" # Blue
On_IPurple="\e[0;105m" # Purple
On_ICyan="\e[0;106m" # Cyan
On_IWhite="\e[0;107m" # White
colors() {
local fgc bgc vals seq0
printf "Color escapes are %s\n" '\e[${value};...;${value}m'
printf "Values 30..37 are \e[33mforeground colors\e[m\n"
printf "Values 40..47 are \e[47mbackground colors\e[m\n"
printf "Value 1 gives a \e[1mbold-faced look\e[m\n\n"
# foreground colors
for fgc in {30..37}; do
# background colors
for bgc in {40..47}; do
fgc=${fgc#37} # white
bgc=${bgc#40} # black
vals="${fgc:+$fgc;}${bgc}"
vals=${vals%%;}
seq0="${vals:+\e[${vals}m}"
printf " %-9s" "${seq0:-(default)}"
printf " ${seq0}TEXT\e[m"
printf " \e[${vals:+${vals+$vals;}}1mBOLD\e[m"
done
echo; echo
done
printf "Values 90..97 are \e[93mhigh intensity fg colors\e[m\n"
printf "Values 100..107 are \e[107mhigh intensity bg colors\e[m\n\n"
# foreground colors
for fgc in {90..97}; do
# background colors
for bgc in {100..107}; do
fgc=${fgc#97} # white
bgc=${bgc#100} # black
vals="${fgc:+$fgc;}${bgc}"
vals=${vals%%;}
seq0="${vals:+\e[${vals}m}"
printf " %-9s" "${seq0:-(default)}"
printf " ${seq0}TEXT\e[m"
printf " \e[${vals:+${vals+$vals;}}1mBOLD\e[m"
done
echo; echo
done
}
#************************************************#
# SHML - Shell Markup Language Framework
# v1.0.2
# (MIT)
# by Justin Dorfman - @jdorfman
# && Joshua Mervine - @mervinej
#
# https://maxcdn.github.io/shml/
#************************************************#
# Foreground (Text)
##
fgcolor() {
local __end='\033[39m'
local __color=$__end # end by default
case "$1" in
end|off|reset) __color=$__end;;
black|000000) __color='\033[30m';;
red|F00BAF) __color='\033[31m';;
green|00CD00) __color='\033[32m';;
yellow|CDCD00) __color='\033[33m';;
blue|0286fe) __color='\033[34m';;
magenta|e100cc) __color='\033[35m';;
cyan|00d3cf) __color='\033[36m';;
gray|e4e4e4) __color='\033[90m';;
darkgray|4c4c4c) __color='\033[91m';;
lightgreen|00fe00) __color='\033[92m';;
lightyellow|f8fe00) __color='\033[93m';;
lightblue|3a80b5) __color='\033[94m';;
lightmagenta|fe00fe) __color='\033[95m';;
lightcyan|00fefe) __color='\033[96m';;
white|ffffff) __color='\033[97m';;
esac
if test "$2"; then
echo -en "$__color$2$__end"
else
echo -en "$__color"
fi
}
# Backwards Compatibility
color() {
fgcolor "$@"
}
# Aliases
fgc() {
fgcolor "$@"
}
c() {
fgcolor "$@"
}
# Background
##
bgcolor() {
local __end='\033[49m'
local __color=$__end # end by default
case "$1" in
end|off|reset) __color=$__end;;
black|000000) __color='\033[40m';;
red|F00BAF) __color='\033[41m';;
green|00CD00) __color='\033[42m';;
yellow|CDCD00) __color='\033[43m';;
blue|0286fe) __color='\033[44m';;
magenta|e100cc) __color='\033[45m';;
cyan|00d3cf) __color='\033[46m';;
gray|e4e4e4) __color='\033[47m';;
darkgray|4c4c4c) __color='\033[100m';;
lightred) __color='\033[101m';;
lightgreen|00fe00) __color='\033[102m';;
lightyellow|f8fe00) __color='\033[103m';;
lightblue|3a80b5) __color='\033[104m';;
lightmagenta|fe00fe) __color='\033[105m';;
lightcyan|00fefe) __color='\033[106m';;
white|fffff) __color='\033[107m';;
esac
if test "$2"; then
echo -en "$__color$2$__end"
else
echo -en "$__color"
fi
}
#Backwards Compatibility
background() {
bgcolor "$@"
}
#Aliases
bgc() {
bgcolor "$@"
}
bg() {
bgcolor "$@"
}
## Color Bar
color-bar() {
if test "$2"; then
for i in "$@"; do
echo -en "$(background "$i" " ")"
done; echo
else
for i in {16..21}{21..16}; do
echo -en "\033[48;5;${i}m \033[0m"
done; echo
fi
}
#Alises
cb() {
color-bar "$@"
}
bar() {
color-bar "$@"
}
## Attributes
##
attribute() {
local __end='\033[0m'
local __attr=$__end # end by default
case "$1" in
end|off|reset) __attr=$__end;;
bold) __attr='\033[1m';;
dim) __attr='\033[2m';;
underline) __attr='\033[4m';;
blink) __attr='\033[5m';;
invert) __attr='\033[7m';;
hidden) __attr='\033[8m';;
esac
if test "$2"; then
echo -en "$__attr$2$__end"
else
echo -en "$__attr"
fi
}
a() {
attribute "$@"
}
## Elements
br() {
echo -e "\n\r"
}
tab() {
echo -e "\t"
}
indent() {
local __len=4
if test "$1"; then
if [[ $1 =~ $re ]] ; then
__len=$1
fi
fi
while [ $__len -gt 0 ]; do
echo -n " "
__len=$(( $__len - 1 ))
done
}
i() {
indent "$@"
}
hr() {
local __len=60
local __char='-'
if ! test "$2"; then
re='^[0-9]+$'
if [[ $1 =~ $re ]] ; then
__len=$1
elif test "$1"; then
__char=$1
fi
else
__len=$2
__char=$1
fi
while [ $__len -gt 0 ]; do
echo -n "$__char"
__len=$(( $__len - 1 ))
done
}
# Icons
##
icon() {
local i='';
case "$1" in
check|checkmark) i='\xE2\x9C\x93';;
X|x|xmark) i='\xE2\x9C\x98';;
'<3'|heart) i='\xE2\x9D\xA4';;
sun) i='\xE2\x98\x80';;
'*'|star) i='\xE2\x98\x85';;
darkstar) i='\xE2\x98\x86';;
umbrella) i='\xE2\x98\x82';;
flag) i='\xE2\x9A\x91';;
snow|snowflake) i='\xE2\x9D\x84';;
music) i='\xE2\x99\xAB';;
scissors) i='\xE2\x9C\x82';;
tm|trademark) i='\xE2\x84\xA2';;
copyright) i='\xC2\xA9';;
apple) i='\xEF\xA3\xBF';;
skull|bones) i='\xE2\x98\xA0';;
':-)'|':)'|smile|face) i='\xE2\x98\xBA';;
*)
entity $1; return 0;;
esac
echo -ne "$i";
}
emoji() {
local i=""
case "$1" in
1F603|smiley|'=)'|':-)'|':)') i='๐';;
1F607|innocent|halo) i='๐';;
1F602|joy|lol|laughing) i='๐';;
1F61B|tongue|'=p'|'=P') i='๐';;
1F60A|blush|'^^'|blushing) i='๐';;
1F61F|worried|sadface|sad) i='๐';;
1F622|cry|crying|tear) i='๐ข';;
1F621|rage|redface) i='๐ก';;
1F44B|wave|hello|goodbye) i='๐';;
1F44C|ok_hand|perfect|okay|nice) i='๐';;
1F44D|thumbsup|+1|like) i='๐';;
1F44E|thumbsdown|-1|no|dislike) i='๐';;
1F63A|smiley_cat|happycat) i='๐บ';;
1F431|cat|kitten|:3|kitty) i='๐ฑ';;
1F436|dog|puppy) i='๐ถ';;
1F41D|bee|honeybee|bumblebee) i='๐';;
1F437|pig|pighead) i='๐ท';;
1F435|monkey_face|monkey) i='๐ต';;
1F42E|cow|happycow) i='๐ฎ';;
1F43C|panda_face|panda|shpanda) i='๐ผ';;
1F363|sushi|raw|sashimi) i='๐ฃ';;
1F3E0|home|house) i='๐ ';;
1F453|eyeglasses|bifocals) i='๐';;
1F6AC|smoking|smoke|cigarette) i='๐ฌ';;
1F525|fire|flame|hot|snapstreak) i='๐ฅ';;
1F4A9|hankey|poop|shit) i='๐ฉ';;
1F37A|beer|homebrew|brew) i='๐บ';;
1F36A|cookie|biscuit|chocolate) i='๐ช';;
1F512|lock|padlock|secure) i='๐';;
1F513|unlock|openpadlock) i='๐';;
2B50|star|yellowstar) i='โญ';;
1F0CF|black_joker|joker|wild) i='๐';;
2705|white_check_mark|check) i='โ
';;
274C|x|cross|xmark) i='โ';;
1F6BD|toilet|restroom|loo) i='๐ฝ';;
1F514|bell|ringer|ring) i='๐';;
1F50E|mag_right|search|magnify) i='๐';;
1F3AF|dart|bullseye|darts) i='๐ฏ';;
1F4B5|dollar|cash|cream) i='๐ต';;
1F4AD|thought_balloon|thinking) i='๐ญ';;
1F340|four_leaf_clover|luck) i='๐';;
*)
#entity $1; return 0;;
esac
echo -ne "$i"
}
function e {
emoji "$@"
}