From dedec42d4736ce205f6eb5b9ebbe7a28f679d754 Mon Sep 17 00:00:00 2001 From: Eric Loyd Date: Thu, 2 Sep 2021 17:28:41 -0400 Subject: [PATCH] Add 'colors.sh' --- colors.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 colors.sh diff --git a/colors.sh b/colors.sh new file mode 100644 index 0000000..52e5a18 --- /dev/null +++ b/colors.sh @@ -0,0 +1,20 @@ +verbose () { + echo $2 "${color_green}$1${color_normal}" +} +error () { + echo $2 "${color_red}$1${color_normal}" + } +warning () { + echo $2 "${color_yellow}$1${color_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 + color_normal="$(tput sgr0)" + color_red="$(tput setaf 1)" + color_green="$(tput setaf 2)" + color_yellow="$(tput setaf 3)" + fi +fi \ No newline at end of file