#!/usr/bin/env bash # 256 colour functions usage # source ./pb # printf %b "$(bg 196)$(fg 254) RED $(nc)\n" nc () { printf '\033[0;0m'; exit; } fg () { if [ -z "$1" ] || [ "$1" -eq "$1" ] >/dev/null 2>&1; then true else echo "bad parameter"; exit; fi local x x=$(tput colors) if (("$1" < 256)) && (("$x" > 255)); then printf %s "\033[38;5;$1m" fi } bg () { if [ -z "$1" ] || [ "$1" -eq "$1" ] >/dev/null 2>&1; then true else echo "bad parameter"; exit; fi local x x=$(tput colors) if (("$1" < 256)) && (("$x" > 255)); then printf %s "\033[48;5;$1m" fi } # end 256 colour functions