Last active
August 29, 2015 14:02
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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