]> git.wh0rd.org - home.git/commitdiff
bash-colors: add named colors
authorMike Frysinger <vapier@gentoo.org>
Fri, 14 Nov 2014 01:51:00 +0000 (20:51 -0500)
committerMike Frysinger <vapier@gentoo.org>
Fri, 14 Nov 2014 01:51:00 +0000 (20:51 -0500)
.bin/bash-colors

index 820958b67f5b341673e2303a54c55a13bbcea481..a2bdff87cac23f382735709aa893641ded012710 100755 (executable)
@@ -59,6 +59,31 @@ main() {
                        "$0" ${x}
                done
                ;;
+       ncurses|curses|mutt|nano)
+               colors=(
+                       black
+                       red
+                       green
+                       yellow
+                       blue
+                       magenta
+                       cyan
+                       white
+               )
+               norm=$(tput sgr0)
+               bold=$(tput bold)
+               blackfg=$(tput setaf 0)
+               for seta in "af" "ab" ; do
+                       [[ ${seta} == "af" ]] && ground=fore || ground=back
+                       for pfx in "" "bright" ; do
+                               for (( i = 0; i < ${#colors[@]}; ++i )) ; do
+                                       [[ ${pfx} == "bright" ]] && printf "${bold}"
+                                       [[ ${seta} == "ab" ]] && printf "${blackfg}"
+                                       echo "$(tput set${seta} ${i})this is ${ground}ground color '${pfx}${colors[i]}'${norm}"
+                               done
+                       done
+               done
+               ;;
        *)
                cat <<-EOF
                        usage: $0 [colors]
@@ -69,6 +94,7 @@ main() {
                         - cube, 6x6x6  - show most extended colors
                         - gray         - show gray scale
                         - all, 256     - show all colors
+                        - curses       - show ncurses color names (used by mutt, nano, etc...)
                EOF
                exit 1
                ;;