]> Tony Duckles's Git Repositories (git.nynim.org) - dotfiles.git/blob - bin/colortable
bin/git-ack: ack-based replacement for "git grep ..."
[dotfiles.git] / bin / colortable
1 #!/bin/bash
2 # Usage: colortable [-x]
3 #
4 # Print a color table of ANSI colors (normal+bright) to demonstrate what
5 # colors are available. Each line is the color code of one foreground
6 # color, out of 17 (default + 16 escapes), followed by a test use of that
7 # color on all nine background colors (default + 8 escapes).
8 #
9 # (Based on: http://www.faqs.org/docs/Linux-HOWTO/Bash-Prompt-HOWTO.html)
10
11 T='gYw' # The test text
12 bright=0 # Don't print bright colors by default
13 test "$1" = "-x" -o "$1" = "-a" && bright=1
14
15 # Standard background colors
16 echo
17 echo -e " 40m 41m 42m 43m 44m 45m 46m 47m";
18 for FGs in ' m' ' 1m' \
19 ' 30m' ' 90m' '1;30m' \
20 ' 31m' ' 91m' '1;31m' \
21 ' 32m' ' 92m' '1;32m' \
22 ' 33m' ' 93m' '1;33m' \
23 ' 34m' ' 94m' '1;34m' \
24 ' 35m' ' 95m' '1;35m' \
25 ' 36m' ' 96m' '1;36m' \
26 ' 37m' ' 97m' '1;37m'; do
27 FG=${FGs// /}
28 if [ "${FG:0:1}" != "9" -o $bright -eq 1 ]; then
29 echo -en " $FGs \033[$FG $T \033[0m"
30 for BG in 40m 41m 42m 43m 44m 45m 46m 47m; do
31 echo -en " \033[$FG\033[$BG $T \033[0m";
32 done
33 echo;
34 fi
35 done
36 echo
37
38 # Bright background colors
39 test $bright -eq 0 && exit 0
40 echo -e " 100m 101m 102m 103m 104m 105m 106m 107m";
41 for FGs in ' m' ' 1m' \
42 ' 30m' ' 90m' '1;30m' \
43 ' 31m' ' 91m' '1;31m' \
44 ' 32m' ' 92m' '1;32m' \
45 ' 33m' ' 93m' '1;33m' \
46 ' 34m' ' 94m' '1;34m' \
47 ' 35m' ' 95m' '1;35m' \
48 ' 36m' ' 96m' '1;36m' \
49 ' 37m' ' 97m' '1;37m'; do
50 FG=${FGs// /}
51 echo -en " $FGs \033[$FG $T \033[0m"
52 for BG in 100m 101m 102m 103m 104m 105m 106m 107m; do
53 echo -en " \033[$FG\033[$BG $T \033[0m";
54 done
55 echo;
56 done
57 echo