#!/usr/local/bin/bash

function highlight() {
        esc="\033["
        if [ "$2" = "y" ] ; then
                bold=";1m"
        else
                bold="m"
        fi
        case "$1" in 
                grey|black) echo -ne "${esc}40;30${bold}"
                ;;
                red)        echo -ne "${esc}40;31${bold}"
                ;;
                green)      echo -ne "${esc}40;32${bold}"
                ;;
                yellow)     echo -ne "${esc}40;33${bold}"
                ;;
                blue)       echo -ne "${esc}40;34${bold}"
                ;;
                magenta)    echo -ne "${esc}40;35${bold}"
                ;;
                cyan)       echo -ne "${esc}40;36${bold}"
                ;;
                white)      echo -ne "${esc}40;37${bold}"
                ;;
                normal)     echo -ne "${esc}0m"
                ;;
                *)          echo -ne "${esc}44;32;1m"
                ;;
        esac
}


if [ "$#" -lt 2 ] ; then
	echo "Usage: $0 <bright?> <color> <text>" > /dev/stderr
	exit 1
fi

if [ "$1" = "bright" ] ; then
	hi=y
fi

highlight "$2" $hi

shift 2

echo "$@"

highlight normal y
