diff options
Diffstat (limited to 'pb_colour')
| -rwxr-xr-x | pb_colour | 24 | 
1 files changed, 11 insertions, 13 deletions
@@ -1,6 +1,8 @@  #!/usr/bin/env bash -#--- 88/256 colour functions  +#--- colour functions +# tested on 16/88/256/truecolor TERM definitions +# limited to 256 colours  # usage:  #   source ./pb  #   printf %b "$(pb_bg 196)$(pb_fg 254) RED $(pb_nc)\n" @@ -8,19 +10,19 @@  pb_ctest() {    if [ -z "$TERM" ] ; then -    return 0 +    return 1    fi -  case $1 in '' | *[!0-9]* ) return 0;; esac +  case $1 in '' | *[!0-9]* ) return 1;; esac    local x    x=$(tput colors)    if [ -z "$1" ] || (("$1" > "$x")) ; then -    return 0 +    return 1    fi - -  return 1 +   +  return 0  }  pb_terminfo() { @@ -31,17 +33,13 @@ pb_terminfo() {  pb_nc() { -  if eval pb_ctest ; then      printf '\033[0;0m' -    return 0 -  else -    return 1 -  fi  	 +  }  pb_fg() { -  if eval pb_ctest ; then +  if pb_ctest $1; then      printf %s "\033[38;5;$1m"      return 0    else @@ -52,7 +50,7 @@ pb_fg() {  pb_bg() { -  if eval pb_ctest ; then +  if pb_ctest $1; then      printf %s "\033[48;5;$1m"      return 0    else  | 
