-
Notifications
You must be signed in to change notification settings - Fork 38
/
colortest
executable file
·66 lines (66 loc) · 1.53 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
#!/usr/bin/env bash
theme=$(dirname $0)/scripts/${1:-base16-default-dark.sh}
if [ -f $theme ]; then
# get the color declarations in said theme, assumes there is a block of text that starts with color00= and ends with new line
source $theme
eval $(awk '/^color00=/,/^$/ {print}' $theme | sed 's/#.*//')
else
printf "No theme file %s found\n" $theme
fi;
ansi_mappings=(
Black
Red
Green
Yellow
Blue
Magenta
Cyan
White
Bright_Black
Bright_Red
Bright_Green
Bright_Yellow
Bright_Blue
Bright_Magenta
Bright_Cyan
Bright_White
)
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 `seq -w 0 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]}
current_color_label=${current_color:-unknown}
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$color_variable")
printf "%s %s %s %-30s %s\x1b[0m\n" $foreground $base16_color_name $current_color_label ${ansi_label:-""} $block
done;
if [ $# -eq 1 ]; then
printf "To restore current theme, source ~/.base16_theme or reopen your terminal\n"
fi