From 9aac1e4d58faadf7841de2618ab9316dcba41074 Mon Sep 17 00:00:00 2001 From: Michael Rappazzo Date: Sun, 7 Feb 2016 08:26:37 -0500 Subject: [PATCH] Options: Add an option to force non-colored output If the output is to be consumed by an application which does not handle formatted output, the script can be invoked with `--no-color` or `-p` to omit the formatting. --- spotify | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/spotify b/spotify index ad13bac..80bdfe3 100755 --- a/spotify +++ b/spotify @@ -28,7 +28,7 @@ showHelp () { echo "Usage:"; echo; - echo " `basename $0` "; + echo " `baseline $0` [--no-color|-p] "; echo; echo "Commands:"; echo; @@ -57,9 +57,11 @@ showHelp () { } cecho(){ - bold=$(tput bold); - green=$(tput setaf 2); - reset=$(tput sgr0); + if [ ! $no_color ]; then + bold=$(tput bold); + green=$(tput setaf 2); + reset=$(tput sgr0); + fi echo $bold$green"$1"$reset; } @@ -87,6 +89,10 @@ else sleep 2 fi fi +if [ $1 == "--no-color" ] || [ $1 == "-p" ]; then + no_color=1 + shift +fi while [ $# -gt 0 ]; do arg=$1;