-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolortest
executable file
·98 lines (89 loc) · 2.32 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
#!/bin/bash
##########################
## Test #1 ###############
##########################
# Load theme
theme=${1:-`dirname $0`/base16-colors.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
eval $(awk '/^color00=/,/^$/ {print}' $theme | sed 's/#.*//')
else
printf "No theme file %s found\n" $theme
fi;
# First color test
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;
##########################
## Test #2 ###############
##########################
echo
python -c "print('\n'.join([(' '.join([('\033[38;5;' + str((i + j)) + 'm' + str((i + j)).ljust(5) + '\033[0m') if i + j < 256 else '' for j in range(16)])) for i in range(0, 256, 16)]))";
##########################
## Test #3 ###############
##########################
T='gYw' # The test text
echo -e "\n 40m 41m 42m 43m\
44m 45m 46m 47m";
for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' \
'1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' \
' 36m' '1;36m' ' 37m' '1;37m';
do FG=${FGs// /}
echo -en " $FGs \033[$FG $T "
for BG in 40m 41m 42m 43m 44m 45m 46m 47m;
do echo -en "$EINS \033[$FG\033[$BG $T \033[0m";
done
echo;
done
echo