#!/bin/bash

# Colors
end="\033[0m"
black="\033[0;30m"
blackb="\033[1;30m"
white="\033[0;37m"
whiteb="\033[1;37m"
red="\033[0;31m"
redb="\033[1;31m"
green="\033[0;32m"
greenb="\033[1;32m"
yellow="\033[0;33m"
yellowb="\033[1;33m"
blue="\033[0;34m"
blueb="\033[1;34m"
purple="\033[0;35m"
purpleb="\033[1;35m"
lightblue="\033[0;36m"
lightblueb="\033[1;36m"

function color.black {
  echo -e "${black}${1}${end}"
}

function color.blackb {
  echo -e "${blackb}${1}${end}"
}

function color.white {
  echo -e "${white}${1}${end}"
}

function color.whiteb {
  echo -e "${whiteb}${1}${end}"
}

function color.red {
  echo -e "${red}${1}${end}"
}

function color.redb {
  echo -e "${redb}${1}${end}"
}

function color.green {
  echo -e "${green}${1}${end}"
}

function color.greenb {
  echo -e "${greenb}${1}${end}"
}

function color.yellow {
  echo -e "${yellow}${1}${end}"
}

function color.yellowb {
  echo -e "${yellowb}${1}${end}"
}

function color.blue {
  echo -e "${blue}${1}${end}"
}

function color.blueb {
  echo -e "${blueb}${1}${end}"
}

function color.purple {
  echo -e "${purple}${1}${end}"
}

function color.purpleb {
  echo -e "${purpleb}${1}${end}"
}

function color.lightblue {
  echo -e "${lightblue}${1}${end}"
}

function color.lightblueb {
  echo -e "${lightblueb}${1}${end}"
}

function color.colors {
  black "black"
  blackb "blackb"
  white "white"
  whiteb "whiteb"
  red "red"
  redb "redb"
  green "green"
  greenb "greenb"
  yellow "yellow"
  yellowb "yellowb"
  blue "blue"
  blueb "blueb"
  purple "purple"
  purpleb "purpleb"
  lightblue "lightblue"
  lightblueb "lightblueb"
}

function color.colortest {
  if [[ -n "$1" ]]; then
    T="$1"
  fi
  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
}
