-
Notifications
You must be signed in to change notification settings - Fork 6
/
colortest.sh
executable file
·60 lines (60 loc) · 1.02 KB
/
colortest.sh
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
#!/usr/bin/env bash
ansi_mappings=(
Black
Red
Green
Yellow
Blue
Magenta
Cyan
''
''
''
''
''
''
''
''
''
Orange
Purple
''
''
''
''
)
colors=(
base00
base08
base0B
base0A
base0D
base0E
base0C
base05
base03
base08
base0B
base0A
base0D
base0E
base0C
base07
base09
base0F
base01
base02
base04
base06
)
for padded_value in 00 01 02 03 04 05 06 07 08 15 16 17 18 19 20 21; do
color_variable="color${padded_value}"
eval current_color=\$${color_variable}
current_color=$(echo ${current_color//\//} | tr '[:lower:]' '[:upper:]') # get rid of slashes, and uppercase
non_padded_value=$((10#$padded_value))
base16_color_name=${colors[$non_padded_value]}
ansi_label=${ansi_mappings[$non_padded_value]}
block=$(printf "\x1b[48;5;${non_padded_value}m___________________________")
foreground=$(printf "\x1b[38;5;${non_padded_value}m")
printf "%s %s %-16s %s%s\x1b[0m\n" $base16_color_name $color_variable ${ansi_label:-""} $foreground $block
done | sort