Skip to content

Instantly share code, notes, and snippets.

@dbechrd
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbechrd/5e69d5129296c43251d6 to your computer and use it in GitHub Desktop.
Save dbechrd/5e69d5129296c43251d6 to your computer and use it in GitHub Desktop.
Some helpful colored output functions that I use in my Git shell scripts on Windows.
CLR='\e[0m'
RED='\e[00;31m'
GREEN='\e[00;32m'
YELLOW='\e[00;33m'
BLUE='\e[00;34m'
PURPLE='\e[00;35m'
CYAN='\e[00;36m'
LIGHTGRAY='\e[00;37m'
LRED='\e[01;31m'
LGREEN='\e[01;32m'
LYELLOW='\e[01;33m'
LBLUE='\e[01;34m'
LPURPLE='\e[01;35m'
LCYAN='\e[01;36m'
WHITE='\e[01;37m'
function Print {
if [ $# -ge 2 ] ; then
printf "%b" "${!2}$1${CLR}"
elif [ $# -eq 1 ] ; then
printf "%b" "$1"
fi
}
function PrintLn {
if [ $# -ge 2 ] ; then
printf "%b" "${!2}$1${CLR}\n"
elif [ $# -eq 1 ] ; then
printf "%b" "$1\n"
else
printf "%b" "\n"
fi
}
PrintLn
Print "Roses are "
Print "red" RED
PrintLn ","
Print "Violets are "
Print "blue" CYAN
PrintLn ","
Print "Escape sequences are "
Print "useful" YELLOW
PrintLn ","
Print "But this is convenience "
Print "anew" GREEN
PrintLn "."
PrintLn
read -p "Press any key..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment