Enhance Add colours (#21)

added colour support in a way that will not screw up the console if
colour support is not available
Used US spelling ;p
If approved will add to remaining scripts
This commit is contained in:
Mafoo
2016-06-14 01:40:49 +01:00
committed by FusionPBX
parent 70a03da58f
commit 76eb530f3b
3 changed files with 89 additions and 29 deletions

25
debian/resources/colors.sh vendored Normal file
View File

@@ -0,0 +1,25 @@
#!/bin/sh
verbose () {
echo "${green}$1${normal}"
}
error () {
echo "${red}$1${normal}"
}
warning () {
echo "${yellow}$1${normal}"
}
# check for color support
if test -t 1; then
# see if it supports colors...
ncolors=$(tput colors)
if test -n "$ncolors" && test $ncolors -ge 8; then
normal="$(tput sgr0)"
red="$(tput setaf 1)"
green="$(tput setaf 2)"
yellow="$(tput setaf 3)"
fi
fi