-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcolortable.sh
executable file
·45 lines (40 loc) · 1.07 KB
/
colortable.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
#!/bin/bash
#---
# Just a simple typical display of colors supported by the terminal
#---
color16() {
# prints a color table of 8bg * 8fg * 2 states (regular/bold)
printf "Table for 16-color terminal escape sequences.\n\n"
echo "Background | Foreground colors"
echo "---------------------------------------------------------------------"
for((bg=40;bg<=47;bg++)); do
for((bold=0;bold<=1;bold++)) do
printf "\033[0m"" ESC[${bg}m | "
for((fg=30;fg<=37;fg++)); do
if [ $bold == "0" ]; then
printf "\033[${bg}m\033[${fg}m [${fg}m "
else
printf "\033[${bg}m\033[1;${fg}m [1;${fg}m"
fi
done
echo -e "\033[0m"
done
echo "--------------------------------------------------------------------- "
done
printf "\n\n"
}
color256() {
cat <<EOF
Table for 256-color terminal escape sequences.
To use as foreground: ESC[38;5;NUMBERm
To use as background: ESC[48;5;NUMBERm
EOF
## Show colors
for x in $( seq -w 0 255 )
do
printf "\033[38;5;${x}m${x}\033[00m \033[48;5;${x}m${x}\033[00m "
done
printf "\n"
}
color256
color16