-
Notifications
You must be signed in to change notification settings - Fork 217
/
colortest
executable file
·108 lines (98 loc) · 2.29 KB
/
colortest
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
#!/usr/bin/env sh
if [ -n "$BASE16_THEME" ]; then
current_theme="base16-$BASE16_THEME"
fi
if [ -n "$BASE24_THEME" ]; then
current_theme="base24-$BASE24_THEME"
fi
theme_name="${1:-${current_theme:-default-dark}}"
theme_path="$(dirname "$0")/scripts/$theme_name.sh"
if [ -f "$theme_path" ]; then
. "$theme_path"
eval "$(awk '/^color00=/,/^$/ {print}' "$theme_path" | sed 's/#.*//')"
else
printf "No theme file %s found\n" "$theme_path"
fi
case "$theme_name" in
"base16"*)
color_variables="\
base00 \
base08 \
base0B \
base0A \
base0D \
base0E \
base0C \
base05 \
base03 \
base08 \
base0B \
base0A \
base0D \
base0E \
base0C \
base07 \
base09 \
base0F \
base01 \
base02 \
base04 \
base06";;
"base24"*)
color_variables="\
base00 \
base08 \
base0B \
base09 \
base0D \
base0E \
base0C \
base06 \
base02 \
base12 \
base14 \
base13 \
base16 \
base17 \
base15 \
base07 \
base09 \
base0F \
base01 \
base02 \
base04 \
base06";;
*) echo "Theme name should start with the scheme system, eg \"base16-oceanicnext\" or \"base24-chalk\": $theme_name" && exit 1 ;;
esac
ansi_labels="\
Black \
Red \
Green \
Yellow \
Blue \
Magenta \
Cyan \
White \
Bright_Black \
Bright_Red \
Bright_Green \
Bright_Yellow \
Bright_Blue \
Bright_Magenta \
Bright_Cyan \
Bright_White"
set -- $color_variables
i=0
while [ $i -lt 22 ]; do
color_variable="color$(printf "%02d" $i)"
eval current_color=\$$color_variable
current_color=$(printf "%s" "$current_color" | tr 'a-f' 'A-F' | tr -d '/') # POSIX-compliant uppercase & remove slashes
# Fetching the color name and ANSI label based on position
base16_color_name=$(printf "%s\n" $color_variables | sed -n "$((i + 1))p")
ansi_label=$(printf "%s\n" $ansi_labels | sed -n "$((i + 1))p")
# Displaying the color block
block=$(printf "\033[48;5;%dm___________________________" $i)
foreground=$(printf "\033[38;5;%dm%s" $i "$color_variable")
printf "%s %s %s %-30s %s\033[0m\n" "$foreground" "$base16_color_name" "${current_color:-space}" "${ansi_label:-""}" "$block"
i=$((i + 1))
done