-
Notifications
You must be signed in to change notification settings - Fork 0
/
.colors
546 lines (466 loc) · 24.6 KB
/
.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
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
#!/usr/bin/env bash
#
# 88
# 888
# 888
# .d8888b .d88b. 888 .d88b. 888d888 .d8888b
# d88P" d88""88b 888 d88""88b 888P" 88K
# 888 888 888 888 888 888 888 "Y8888b.
# d8b Y88b. Y88..88P 888 Y88..88P 888 X88
# Y8P "Y8888P "Y88P" 888 "Y88P" 888 88888P'
#
# -------------------------------------------------------------------------
# Version: 0.1
# File: .colors
# Source: https://github.com/devpunks
# Author: Ahmid-Ra (github.com/snuggs)
# Maintainer: devPunks <https://github.com/devpunks>
# Description: Color configuration
# -------------------------------------------------------------------------
#
# - Benchmark - https://imgur.com/xIyuaYt
# - https://github.com/termstandard/colors
# - https://stackoverflow.com/q/27159322
# - https://en.m.wikipedia.org/wiki/Color_Graphics_Adapter
# - https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797
# - https://wikipedia.org/wiki/List_of_monochrome_and_RGB_color_formats
# - ANSI Escape Codes - https://en.m.wikipedia.org/wiki/ANSI_escape_code
# - TERM COLOR DISCUSSION - https://news.ycombinator.com/item?id=30483899
#
# Note: Some control escape sequences, like \e for ESC, are not guaranteed
# to work in all languages and compilers. It is recommended to use
# the decimal 27, octal \033, or hex \x1B representation as escape code.
#
# =========================================================================
# {{{ Environment Color Codes
#
# =========================================================================
export CLICOLOR=1 # Defaults - https://stackoverflow.com/q/41849875
# https://github.com/eza-community/eza
# https://the.exa.website/docs/colour-themes
export EXA_COLORS='
:hd=1;4;38;5;13;48;5;8:sb=1;4;38;5;13:sn=1;4;38;5;13:da=3;38;5;13:uu=2;38;5;13:gd=1;4;38;5;2:
'
# LS_COLORS
export DIRCOLORS="$HOME/.dircolors"
# https://gnu.org/software/coreutils/manual/html_node/dircolors-invocation.html
# TODO: Fix
[ -e "$DIRCOLORS" ] && eval $( dircolors -b "$DIRCOLORS" )
[ -e "$DIRCOLORS" ] && source "$DIRCOLORS"
# GREP_COLORS
# https://askubuntu.com/q/1042234
# https://gnu.org/software/grep/manual/grep.html#index-GREP_005fCOLORS-environment-variable
export GREP_COLORS=':fn=1;4:se=1:ln=1;2;3:sl=2:cx=2;3;9:ms=0;1;4;7:mc=0;1;4;7:mt=0;1;4;7:bn=31:'
# }}}
# =========================================================================
# {{{ ANSI Monochrome
#
# Delimited by opening square bracket ([), known as a
# Control Sequence Introducer (CSI), optionally followed by
# semi-colon (;) delimeted arguments and the command itself.
#
# All common sequences just use the parameters as
# a series of semicolon-separated numbers such as 1;2;3.
# Missing numbers are treated as 0 (1;;3 acts like the middle number is 0,
# and no parameters at all in ESC[m acts like a 0 reset code).
#
#┏━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┓
#┃ ## ┃ GNOME Terminal ┃ xterm ┃ non-GUI TTY ┃
#┡━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━┩
# │ 0 │ «Reset style» │ «Reset style» │ «Reset style»
# │ 1 │ +Bold, +brighter color │ +Bold, +Brighter color │ +Brighter color
# │ 2 │ +Fainter color │ +Fainter color │ +Forced grey
# │ 3 │ +Italic │ +Italic │ +Forced green
# │ 4 │ +Underline │ +Underline │ +Forced cyan
# │ 5 │ «no effect» │ +Blink │ «No effect»
# │ 6 │ «no effect» │ +Blink (fast) │ «No effect»
# │ 7 │ +Reverse video │ +Invert colors │ +Reverse video
# │ 8 │ +Invisible │ +Invisible │ «No effect»
# │ 9 │ +Strikethrough │ +Strikethrough │ «No effect»
#-------------------------- Unset Style -----------------------------------
# │ 21 │ -Bold, -Brighter color │ -Double underline │ -Brighter color
# │ 22 │ -Fainter color │ -Fainter color │ -Forced grey
# │ 23 │ -Italic │ -Italic │ -Forced green
# │ 24 │ -Underline │ -Underline, │ -Forced cyan
# │ 25 │ «No effect» │ -Blink │ «No effect»
# │ 26 │ «No effect» │ -Blink (fast) │ «No effect»
# │ 27 │ -Reverse video │ -Invert colors │ -Reverse video
# │ 28 │ -Invisible │ -Invisible │ «No effect»
# │ 29 │ -Strikethrough │ -Strikethrough │ «No effect»
#──────────────────────────────────────────────────────────────────────────
#
#==========================================================================
# CSI (Control Sequence Introducer) Escape Sequences
# - https://en.m.wikipedia.org/wiki/ANSI_escape_code#CSI_(Control_Sequence_Introducer)_sequences
# -------------------------------------------------------------------------
#
# Ctrl Escape:
# Standard Escape: \e[
# Octal Escape: \033[
# Decimal Escape: \27[
# Unicode Escape: \u001b[
# Hexadecimal Escape: \x1B[
# SGR (Select Graphic Rendition) Styles
# - https://en.m.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters
# -------------------------------------------------------------------------
# Styles Reset - 0, On 0-9, and Off 21-29
# -------------------------------------------------------------------------
# If no codes are given, CSI m ( \e[m ) is treated as CSI 0m ( \e[0m ) (reset / normal).
# - \e[0m Reset \e[m
# - \e[1m Bold \e[21m
# - \e[2m Faint \e[22m
# - \e[3m Italic \e[23m
# - \e[4m Underline \e[24m
# - \e[5m Blink \e[25m
# - \e[6m Blink (Fast) \e[26m
# - \e[7m Reverse \e[27m
# - \e[8m Invisible \e[28m
# - \e[9m Strikethrough \e[29m
#
# -------------------------------------------------------------------------
DEFAULT='\e[0m'
# Monochrome Term(inal) Helpers -------------------------------------------
BOLD='\e[1m' # tput bold
DIM='\e[2m' # tput dim
ITALIC='\e[3m' # tput sitm
UNDERLINE='\e[4m' # tput smul
BLINK='\e[5m' # tput blink
STROBE='\e[6m' # tput ????
REVERSE='\e[7m' # tput rev
INVISIBLE='\e[8m' # tput invis
STRIKE='\e[9m' # tput smso
function Monochrome () {
echo && echo ANSI Monochrome && echo
local styles=(
DEFAULT BOLD DIM ITALIC UNDERLINE
BLINK STROBE REVERSE INVISIBLE STRIKE
)
local CSI='\\e'
for style in "${!styles[@]}"; do
echo " \e[2m${CSI}\e[m\e[1m[${style}m\e[m" \
"➖ \e[${style}m${styles[ $style ]}\e[m" \
" \e[2m${CSI}\e[m\e[1m[2${style}m\e[m"
done && echo
for style in "${!styles[@]}"; do
echo " \e[1m${styles[ $style ]}\e[m ➖ \e[1m\${${styles[ $style ]}}\e[m" \
"$( eval "echo \$${styles[ $style ]}" )The quick brown fox jumped over the lazy dog!\e[m"
done
} # Monochrome
# }}}
# =========================================================================
# {{{ ANSI 3-bit 8-Color
#
# - https://retrocomputing.stackexchange.com/q/20043
#┏━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┓
#┃ ### ┃ GNOME Terminal ┃ xterm ┃ non-GUI TTY ┃
#┡━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━┩
# │ 30 │ Very dark grey │ Black │ Black
# │ 31 │ Dull red │ Red │ Red
# │ 32 │ Dull green │ Green │ │ Green
# │ 33 │ Dull yellow │ Yellow │ Yellow
# │ 34 │ Greyish blue │ Blue │ Blue
# │ 35 │ Dull purple │ Purple │ Magenta
# │ 36 │ Teal │ Cyan │ Cyan
# │ 37 │ Light grey │ White │ White
# │ 39 │ «Normal Reset │ «Normal Reset» │ «Normal Reset»
# │30;1 │ Dark grey │ Bold Black │ Bold Black
# │31;1 │ Red │ Bold Red │ Bold Red
# │32;1 │ Lime green │ Bold Green │ Bold Green
# │33;1 │ Yellow │ Bold Yellow │ Bold Yellow
# │34;1 │ Light greyish blue │ Bold Blue │ Bold Blue
# │35;1 │ Light purple │ Bold Magenta │ Bold Magenta
# │36;1 │ Cyan │ Bold Cyan │ Bold Cyan
# │37;1 │ Off white │ Bold White │ Bold White
#──────────────────────────────────────────────────────────────────────────
#
#==========================================================================
# XTerm X11 ColorSpace Foreground 30-37, 39
# -------------------------------------------------------------------------
BLACK='\e[30m' #000000 RGB( 0,0,0 )
RED='\e[31m' #800000 RGB( 128,0,0 )
GREEN='\e[32m' #008000 RGB( 0,128,0 )
YELLOW='\e[33m' #808000 RGB( 128,128,0 )
BLUE='\e[34m' #000080 RGB( 0,0,128 )
MAGENTA='\e[35m' #800080 RGB( 128,0,128 )
CYAN='\e[36m' #008080 RGB( 0,128,128 )
WHITE='\e[37m' #808080 RGB( 192,192,192 )
# -------------------------------------------------------------------------
NORMAL='\e[39m'
# -------------------------------------------------------------------------
# XTerm X11 ColorSpace Bold Foreground 30;1-37;1
# -------------------------------------------------------------------------
# \e[30m;1- Bold Black #000000 RGB( 0,0,0 )
# \e[31m;1- Bold Red #800000 RGB( 255,0,0 )
# \e[32m;1- Bold Green #008000 RGB( 0,255,0 )
# \e[33m;1- Bold Yellow #808000 RGB( 255,255,0 ) w
# \e[34m;1- Bold Blue #000080 RGB( 0,0,255 )
# \e[35m;1- Bold Magenta #800080 RGB( 255,0,255 ) ta
# \e[36m;1- Bold Cyan #008080 RGB( 0,255,255 )
# \e[37m;1- Bold White #808080 RGB( 255,255,255 )
#┏━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┓
#┃ ### ┃ GNOME Terminal ┃ xterm ┃non-GUI TTY ┃
#┡━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━┩
# │ 40 │ Very dark grey │ Black │ Black
# │ 41 │ Dull red │ Red │ Red
# │ 42 │ Dull green │ Green │ Green
# │ 43 │ Dull yellow │ Yellow │ Yellow
# │ 44 │ Greyish blue │ Blue │ Blue
# │ 45 │ Dull purple │ Magenta │ Magenta
# │ 46 │ Teal │ Cyan │ Cyan
# │ 47 │ White │ Wyite │ White
# │ 49 │ «Normal Reset │ «Normal Reset» │ «Normal Reset»
#------------------------ Bold Video-Reverse ------------------------------
# │30;1;7 │ Dark grey │ Bold Black │ Bold Black
# │31;1;7 │ Red │ Bold Red │ Bold Red
# │32;1;7 │ Lime green │ Bold Green │ Bold Green
# │33;1;7 │ Yellow │ Bold Yellow │ Bold Yellow
# │34;1;7 │ Light greyish blue │ Bold Blue │ Bold Blue
# │35;1;7 │ Light purple │ Bold Magenta │ Bold Magenta
# │36;1;7 │ Cyan │ Bold Cyan │ Bold Cyan
# │37;1;7 │ Off white │ Bold White │ Bold White
#─────────────────────────────────────────────────────────────────────────
# XTerm X11 ColorSpace Background 40-47
# -------------------------------------------------------------------------
BLACK_BG='\e[40m' #000000 RGB( 0,0,0 )
RED_BG='\e[41m' #800000 RGB( 128,0,0 )
GREEN_BG='\e[42m' #008000 RGB( 0,128,0 )
YELLOW_BG='\e[43m' #808000 RGB( 128,128,0 )
BLUE_BG='\e[44m' #000080 RGB( 0,0,128 )
MAGENTA_BG='\e[45m' #800080 RGB( 128,0,128 )
CYAN_BG='\e[46m' #008080 RGB( 0,128,128 )
WHITE_BG='\e[47m' #808080 RGB( 192,192,192 )
#
# -------------------------------------------------------------------------
NORMAL_BG='\e[49m'
# -------------------------------------------------------------------------
# XTerm X11 ColorSpace Bold Video-Reverse Background 30;1;7-37;1;7
# -------------------------------------------------------------------------
# \e[30;1;7m - Bold Black Video-Reverse
# \e[31;1;7m - Bold Red Video-Reverse
# \e[32;1;7m - Bold Green Video-Reverse
# \e[33;1;7m - Bold Yellow Video-Reverse
# \e[34;1;7m - Bold Blue Video-Reverse
# \e[35;1;7m - Bold Magenta Video-Reverse
# \e[36;1;7m - Bold Cyan Video-Reverse
# \e[37;1;7m - Bold White Video-Reverse
# ANSI 3-bit & 4-bit Colorspace(s)
# - https://en.m.wikipedia.org/wiki/ANSI_escape_code#3-bit_and_4-bit
function 3bit () {
local SYSTEM=( NORMAL BLACK RED GREEN YELLOW BLUE MAGENTA CYAN WHITE )
echo '\n\n ANSI 3-bit Helpers'
for color in "${!SYSTEM[@]}"; do
local fg=$( eval "echo \$${SYSTEM[ $color ]}" )
local bg=$( eval "echo \$${SYSTEM[ $color ]}_BG" )
printf "\n ${fg} %-10s \e[m ${bg} %13s \e[m" \
"\${${SYSTEM[ $color ]}}" "\${${SYSTEM[ $color ]}_BG}"
done
echo '\n\n ANSI 3-bit'
printf "\n %9s " ' 🎨'
for BG in $( seq 40 47 ); do
printf "\e[${BG}m %-8s\e[m" "\\e[${BG}m"
done
for FG in $( seq 30 37 ); do
printf "\n\e[${FG}m%-9s\e[m" " \\e[${FG}m ➤"
for BG in $( seq 40 47 ); do
printf "\e[${FG};${BG}m%-9s\e[m" " ${FG};${BG}m"
done
done
echo '\n\n ANSI 3-bit \e[39;1mBright\e[m'
printf "\n %12s " ' 🎨 '
for BG in $( seq 40 47 ); do
printf "\e[${BG}m %-8s \e[m" "\\e[${BG}m"
done
for FG in $( seq 30 37 ); do
printf "\n\e[${FG};1m %-11s \e[m" "\\e[${FG};1m ➤"
for BG in $( seq 40 47 ); do
printf "\e[${FG};1;${BG}m %-8s \e[m" "${FG};1;${BG}m"
done
done
echo '\n\n ANSI 3-bit \e[1;7m Video Reverse \e[m'
printf "\n 🎨 "
for FG in $( seq 30 37 ); do
printf "\e[${FG};7;49m %-8s \e[m" "${FG};7m"
done
printf "\n \e[1mBright 🎨 \e[m "
for FG in $( seq 30 37 ); do
printf "\e[${FG};1;7;49m %-8s \e[m" "${FG};1;7m"
done && echo
} # 3bit
# }}}
# =========================================================================
# {{{ 4-bit AIXterm Light 8-Color
#
# The 16-color feature is borrowed from IBM aixterm,
# which maps 16 codes each for foreground and background onto two ranges;
# - https://github.com/termstandard/colors/issues/19
# - https://wikipedia.org/wiki/List_of_monochrome_and_RGB_color_formats#4-bit_RGBI
#==========================================================================
#┏━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┓
#┃ ### ┃ GNOME Terminal ┃ xterm ┃ non-GUI TTY ┃
#┡━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━┩
# │ 90 │ Dark grey │ Light Black │ Light Black
# │ 91 │ Red │ Light Red │ Light Red
# │ 92 │ Lime green │ Light Green │ Light Green
# │ 93 │ Yellow │ Light Yellow │ Light Yellow
# │ 94 │ Light greyish blue │ Light Blue │ Light Blue
# │ 95 │ Light purple │ Light Magenta │ Light Magenta
# │ 96 │ Cyan │ Light Cyan │ Light Cyan
# │ 97 │ Off white │ Light White │ Light White
#────────────────────────────────────────────────────────────────────────
#
#------------------------- Light Background -----------------------------
#
# │ 100 │ Dark grey │ Light Black │ Light Black
# │ 101 │ Red │ Light Red │ Light Red
# │ 102 │ Lime green │ Light Green │ Light Green
# │ 103 │ Yellow │ Light Yellow │ Light Yellow
# │ 104 │ Light greyish blue │ Light Blue │ Light Blue
# │ 105 │ Light purple │ Light Magenta │ Light Magenta
# │ 106 │ Cyan │ Light Cyan │ Light Cyan
# │ 107 │ Off white │ Light White │ Light White
#────────────────────────────────────────────────────────────────────────
# Light Foreground Helpers (90-97) --------------------------------------
BLACK_LIGHT=$( tput setaf 8 ) # \e[90m
RED_LIGHT=$( tput setaf 9 ) # \e[91m
GREEN_LIGHT=$( tput setaf 10 ) # \e[92m
YELLOW_LIGHT=$( tput setaf 11 ) # \e[93m
BLUE_LIGHT=$( tput setaf 12 ) # \e[94m
MAGENTA_BRIGHT=$( tput setaf 13 ) # \e[95m
CYAN_LIGHT=$( tput setaf 14 ) # \e[96m
WHITE_LIGHT=$( tput setaf 15 ) # \e[97m
# Light Background Colors (100-107) ---\e--------------------------------
BLACK_LIGHT_BG=$( tput setab 8 ) # \e[100m
RED_LIGHT_BG=$( tput setab 9 ) # \e[101m
GREEN_LIGHT_BG=$( tput setab 10 ) # \e[102m
YELLOW_LIGHT_BG=$( tput setab 11 ) # \e[103m
BLUE_LIGHT_BG=$( tput setab 12 ) # \e[104m
MAGENTA_LIGHT_BG=$( tput setab 13 ) # \e[105m
CYAN_LIGHT_BG=$( tput setab 14 ) # \e[106m
WHITE_LIGHT_BG=$( tput setab 15 ) # \e[107m
# ANSI 4-bit Colorspace(s)
# - https://en.m.wikipedia.org/wiki/ANSI_escape_code#3-bit_and_4-bit
function 4bit () {
local SYSTEM=( BLACK RED GREEN YELLOW BLUE MAGENTA CYAN WHITE )
echo '\n\n ANSI 4-bit \e[1mLight\e[m Helpers'
for color in "${!SYSTEM[@]}"; do
local fg=$( eval "echo \$${SYSTEM[ $color ]}_LIGHT" )
local bg=$( eval "echo \$${SYSTEM[ $color ]}_LIGHT_BG" )
printf "\n ${fg} %-16s \e[m ${bg} %20s \e[m" \
"\${${SYSTEM[ $color ]}_LIGHT}" "\${${SYSTEM[ $color ]}_LIGHT_BG}"
done
echo "\n\n ANSI 4-bit \e[1mLight \e[2;3m(AIXTerm Non-Standard)\e[m"
printf "\n %9s " ' 🎨'
for BG in $( seq 100 107 ); do
printf "\e[${BG}m %-8s\e[m" "\\e[${BG}m"
done
for FG in $( seq 90 97 ); do
printf "\n\e[${FG}m%-9s\e[m" " \\e[${FG}m ➤"
for BG in $( seq 100 107 ); do
printf "\e[${FG};${BG}m%-9s\e[m" " ${FG};${BG}m"
done
done && echo
} # 4bit
# }}}
# =========================================================================
# {{{ 8-bit 256 Color
#
# - https://en.m.wikipedia.org/wiki/ANSI_escape_code#8-bit
# - https://ditig.com/publications/256-colors-cheat-sheet#xterm-system-colors
# - https://ditig.com/publications/256-colors-cheat-sheet#xterm-non-system-colors
#
# 256 ansi colors # Where N is a color code {0-256}
# 38;5;n │Foreground - Replace ɴ with value from 256-color chart below
# │for closest supported color (non-GUI TTY has only 16 colors!)
#--------------------------------------------------------------------------
# 48;5;n │Background - Replace ɴ with value from 256-color chart below
# │for closest supported color (non-GUI TTY has only 16 colors!)
# =========================================================================
function 8bit () {
# https://unix.stackexchange.com/q/9957/how-to-check-if-bash-can-print-colors
local columns=6
local fg='\e[38;5;'
local bg='\e[48;5;'
echo "\n\n ANSI 8-bit 256 [2;3m(0-7) [m[1mStandard Colors[m"
printf "\n # [1m %-12s [7m %-12s[m\n\n" Foreground Background
for n in {0..7} ; do
printf " %2s ${fg}%dm \\${fg}%-3s \e[m ${bg}%dm \\${bg}%-3s \e[m\n" \
$n $n "${n}m" $n "${n}m"
done
echo "\n\n ANSI 8-bit 256 [2;3m(8-15) [m[1mHigh-Intensity Colors[m"
printf "\n # [1m %-12s [7m %-12s[m\n\n" Foreground Background
for n in {8..15} ; do
printf " %2s ${fg}%dm \\${fg}%-3s \e[m ${bg}%dm \\${bg}%-3s \e[m\n" \
$n $n "${n}m" $n "${n}m"
done
echo "\n\n ANSI 8-bit 256 [2;3m(16-231) [m[3m(Extended)[m [1m216 Colors[m"
printf "\n # [1m %-12s [7m %-12s[m\n\n" Foreground Background
for n in {16..231} ; do
printf "${fg}%dm %3s \e[m${bg}%dm %3s \e[m" $n "${n}" $n "${n}"
if (( ( n > 15 ) && (n-15) % $columns == 0 ))
then printf "\n";
fi
done
echo "\n\n ANSI 8-bit 256 [2;3m(232-255) [m[1mGrayScale Colors[m"
printf "\n # [1m %-12s [7m %-12s[m\n\n" Foreground Background
for n in {232..255} ; do
printf "${fg}%dm %3s \e[m${bg}%dm %3s \e[m" $n "${n}" $n "${n}"
if (( ( n > 15 ) && (n-15) % $columns == 0 ))
then printf "\n";
fi
done
} # 8bit
# }}}
# =========================================================================
# {{{ 24-Bit True Color
# - https://en.m.wikipedia.org/wiki/ANSI_escape_code#24-bit
#
# 38;2;ʀ;ɢ;ʙ │Foreground - Replace ʀ, ɢ, and ʙ with RGB values from 0 to 255
# for closest supported color (non-GUI TTY has only 16 colors!)
#--------------------------------------------------------------------------
# 48;2;ʀ;ɢ;ʙ │Background - Replace ʀ, ɢ, and ʙ with RGB values from 0 to 255
# for closest supported color (non-GUI TTY has only 16 colors!)
# =========================================================================
# https://github.com/microsoft/terminal/issues/11057
export COLORTERM='24bit' # [24bit|truecolor|xterm-truecolor]
function 24bit () { # https://github.com/JohnMorales/dotfiles/blob/master/colors/24-bit-color.sh
# https://unix.stackexchange.com/q/404414/print-true-color-24-bit-test-pattern/404415#404415
# Truecolor test
printf "\n\e[38;2;255;100;0mTRUECOLOR ${COLORTERM}\e[0m\n"
awk \
-v term_cols="${width:-$( tput cols || echo 80 )}" \
-v term_lines="${height:-$( tput lines || echo 1 )}" \
'BEGIN {
s="/\\";
total_cols=term_cols * term_lines;
for ( colnum = 0; colnum < total_cols; colnum++ ) {
r = 255 - ( colnum * 255 / total_cols );
g = ( colnum * 510 / total_cols );
b = ( colnum * 255 / total_cols );
if ( g > 255 ) g = 510-g;
printf "\033[48;2;%d;%d;%dm", r, g, b;
printf "\033[38;2;%d;%d;%dm", 255 - r, 255 - g, 255 - b;
printf "%s\033[0m", substr( s, colnum % 2 + 1, 1 );
if ( colnum % term_cols==term_cols ) printf "\n";
}
printf "\n";
}' # BEGIN
} # 24bit
# }}}
# =========================================================================
# {{{ Functions
# =========================================================================
function Colors () {
echo && echo "Colors: $( tput colors )"
printf "\n\$GREP_COLORS\n$GREP_COLORS\n"
printf "\n\$LS_COLORS\n$LS_COLORS\n"
printf "\ndircolors -b\n$( dircolors -b )\n"
printf "\ndircolors .dircolors\n$( dircolors "${DIRCOLORS}" )\n"
printf "\ndircolors -b .dircolors\n$( dircolors -b "${DIRCOLORS}" )\n"
printf "\ndircolors --print-ls-colors\n$( dircolors --print-ls-colors )\n"
Monochrome && 3bit && 4bit && 8bit && 24bit
} # Colors
# }}}
echo && echo -E "👤 ${BOLD}$( whoami )${DEFAULT} \
💜s devPunks ${REVERSE}${BOLD}${MAGENTA} .colors ${DEFAULT}${NORMAL}"
echo
# vim: foldmethod=marker