]>
Commit | Line | Data |
---|---|---|
8069c098 | 1 | #!/bin/bash |
412ff3c0 | 2 | # Author: Mike Frysinger <vapier@gmail.com>; released into the public domain; suck it. |
ea2a7d52 | 3 | |
412ff3c0 MF |
4 | show_env() { |
5 | local c colors=( | |
ea2a7d52 MF |
6 | GOOD="\$'\e[32;01m'" |
7 | WARN="\$'\e[33;01m'" | |
8 | BAD="\$'\e[31;01m'" | |
9 | HILITE="\$'\e[36;01m'" | |
583623f9 | 10 | BRACKET="\$'\e[34;01m'" |
ea2a7d52 MF |
11 | NORMAL="\$'\e[0m'" |
12 | ) | |
13 | for c in "${colors[@]}" ; do | |
b73f07c7 | 14 | [[ -t 0 ]] || c="${c%=*}=" |
ea2a7d52 MF |
15 | echo "${c}" |
16 | done | |
412ff3c0 | 17 | } |
ea2a7d52 | 18 | |
412ff3c0 MF |
19 | check256() { |
20 | if [[ ${TERM} != *-256color ]] ; then | |
21 | ( | |
22 | echo "warning: TERM (${TERM}) does not end in '-256color';" | |
23 | echo "warning: trying to use 256 colors might not work." | |
24 | ) >&2 | |
25 | fi | |
26 | } | |
ea2a7d52 | 27 | |
ee33e474 MF |
28 | showit() { |
29 | echo -e '\e['"${1};${2}mthis color is: \\\\e[${1};${2}m \e[0m" | |
30 | } | |
412ff3c0 MF |
31 | |
32 | main() { | |
33 | case $1 in | |
34 | --env) | |
35 | show_env | |
36 | ;; | |
37 | ""|16|system) | |
38 | for i in {0..1} ; do | |
39 | for j in {30..37} ; do | |
40 | showit ${i} ${j} | |
41 | done | |
ee33e474 | 42 | done |
412ff3c0 MF |
43 | ;; |
44 | cube|6x6x6) | |
45 | check256 | |
46 | for n in {16..231} ; do | |
47 | showit "38;05" $(printf '%03i' ${n}) | |
48 | done | |
49 | ;; | |
50 | gr[ae]y) | |
51 | check256 | |
52 | for n in {232..255} ; do | |
53 | showit "38;05" ${n} | |
54 | done | |
55 | ;; | |
56 | all|256) | |
57 | for x in system cube gray ; do | |
58 | echo "### SET: ${x}" | |
59 | "$0" ${x} | |
60 | done | |
61 | ;; | |
62 | *) | |
63 | cat <<-EOF | |
64 | usage: $0 [colors] | |
65 | ||
66 | Colors: | |
67 | - --env - show env you can eval in a shell | |
68 | - 16, system - show basic colors (default) | |
69 | - cube, 6x6x6 - show most extended colors | |
70 | - gray - show gray scale | |
71 | - all, 256 - show all colors | |
72 | EOF | |
73 | exit 1 | |
74 | ;; | |
75 | esac | |
76 | } | |
77 | main "$@" |