Last active
January 17, 2020 14:58
-
-
Save thedava/2cc7e1c7d079f457452f to your computer and use it in GitHub Desktop.
color_echo - Colored Bash echo output
This file contains 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
# Reset | |
Color_None='\e[0m' | |
# Regular Colors | |
Color_Black='\e[0;30m' | |
Color_Red='\e[0;31m' | |
Color_Green='\e[0;32m' | |
Color_Yellow='\e[0;33m' | |
Color_Blue='\e[0;34m' | |
Color_Purple='\e[0;35m' | |
Color_Cyan='\e[0;36m' | |
Color_White='\e[0;37m' | |
# Bold | |
Color_Bold_Black='\e[1;30m' | |
Color_Bold_Red='\e[1;31m' | |
Color_Bold_Green='\e[1;32m' | |
Color_Bold_Yellow='\e[1;33m' | |
Color_Bold_Blue='\e[1;34m' | |
Color_Bold_Purple='\e[1;35m' | |
Color_Bold_Cyan='\e[1;36m' | |
Color_Bold_White='\e[1;37m' | |
# Underline | |
Color_Underline_Black='\e[4;30m' | |
Color_Underline_Red='\e[4;31m' | |
Color_Underline_Green='\e[4;32m' | |
Color_Underline_Yellow='\e[4;33m' | |
Color_Underline_Blue='\e[4;34m' | |
Color_Underline_Purple='\e[4;35m' | |
Color_Underline_Cyan='\e[4;36m' | |
Color_Underline_White='\e[4;37m' | |
# Background | |
Color_Background_Black='\e[40m' | |
Color_Background_Red='\e[41m' | |
Color_Background_Green='\e[42m' | |
Color_Background_Yellow='\e[43m' | |
Color_Background_Blue='\e[44m' | |
Color_Background_Purple='\e[45m' | |
Color_Background_Cyan='\e[46m' | |
Color_Background_White='\e[47m' | |
# High Intensity | |
Color_Intensive_Black='\e[0;90m' | |
Color_Intensive_Red='\e[0;91m' | |
Color_Intensive_Green='\e[0;92m' | |
Color_Intensive_Yellow='\e[0;93m' | |
Color_Intensive_Blue='\e[0;94m' | |
Color_Intensive_Purple='\e[0;95m' | |
Color_Intensive_Cyan='\e[0;96m' | |
Color_Intensive_White='\e[0;97m' | |
# Bold High Intensity | |
Color_Bold_Intensive_Black='\e[1;90m' | |
Color_Bold_Intensive_Red='\e[1;91m' | |
Color_Bold_Intensive_Green='\e[1;92m' | |
Color_Bold_Intensive_Yellow='\e[1;93m' | |
Color_Bold_Intensive_Blue='\e[1;94m' | |
Color_Bold_Intensive_Purple='\e[1;95m' | |
Color_Bold_Intensive_Cyan='\e[1;96m' | |
Color_Bold_Intensive_White='\e[1;97m' | |
# High Intensity backgrounds | |
Color_Background_Intensive_Black='\e[0;100m' | |
Color_Background_Intensive_Red='\e[0;101m' | |
Color_Background_Intensive_Green='\e[0;102m' | |
Color_Background_Intensive_Yellow='\e[0;103m' | |
Color_Background_Intensive_Blue='\e[0;104m' | |
Color_Background_Intensive_Purple='\e[0;105m' | |
Color_Background_Intensive_Cyan='\e[0;106m' | |
Color_Background_Intensive_White='\e[0;107m' | |
function color_echo() { | |
color=$1 | |
text=$2 | |
echo -e "${color}${text}${Color_None}" | |
} |
This file contains 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
#!/bin/bash | |
source color_echo.sh | |
# Regular Colors | |
echo "Regular Colors" | |
color_echo ${Color_Black} " Color_Black" | |
color_echo ${Color_Red} " Color_Red" | |
color_echo ${Color_Green} " Color_Green" | |
color_echo ${Color_Yellow} " Color_Yellow" | |
color_echo ${Color_Blue} " Color_Blue" | |
color_echo ${Color_Purple} " Color_Purple" | |
color_echo ${Color_Cyan} " Color_Cyan" | |
color_echo ${Color_White} " Color_White" | |
echo "" | |
# Bold | |
echo "Bold" | |
color_echo ${Color_Bold_Black} " Color_Bold_Black" | |
color_echo ${Color_Bold_Red} " Color_Bold_Red" | |
color_echo ${Color_Bold_Green} " Color_Bold_Green" | |
color_echo ${Color_Bold_Yellow} " Color_Bold_Yellow" | |
color_echo ${Color_Bold_Blue} " Color_Bold_Blue" | |
color_echo ${Color_Bold_Purple} " Color_Bold_Purple" | |
color_echo ${Color_Bold_Cyan} " Color_Bold_Cyan" | |
color_echo ${Color_Bold_White} " Color_Bold_White" | |
echo "" | |
# Underline | |
echo "Underline" | |
color_echo ${Color_Underline_Black} " Color_Underline_Black" | |
color_echo ${Color_Underline_Red} " Color_Underline_Red" | |
color_echo ${Color_Underline_Green} " Color_Underline_Green" | |
color_echo ${Color_Underline_Yellow} " Color_Underline_Yellow" | |
color_echo ${Color_Underline_Blue} " Color_Underline_Blue" | |
color_echo ${Color_Underline_Purple} " Color_Underline_Purple" | |
color_echo ${Color_Underline_Cyan} " Color_Underline_Cyan" | |
color_echo ${Color_Underline_White} " Color_Underline_White" | |
echo "" | |
# Background | |
echo "Background" | |
color_echo ${Color_Background_Black} " Color_Background_Black" | |
color_echo ${Color_Background_Red} " Color_Background_Red" | |
color_echo ${Color_Background_Green} " Color_Background_Green" | |
color_echo ${Color_Background_Yellow} " Color_Background_Yellow" | |
color_echo ${Color_Background_Blue} " Color_Background_Blue" | |
color_echo ${Color_Background_Purple} " Color_Background_Purple" | |
color_echo ${Color_Background_Cyan} " Color_Background_Cyan" | |
color_echo ${Color_Background_White} " Color_Background_White" | |
echo "" | |
# High Intensity | |
echo "High Intensity" | |
color_echo ${Color_Intensive_Black} " Color_Intensive_Black" | |
color_echo ${Color_Intensive_Red} " Color_Intensive_Red" | |
color_echo ${Color_Intensive_Green} " Color_Intensive_Green" | |
color_echo ${Color_Intensive_Yellow} " Color_Intensive_Yellow" | |
color_echo ${Color_Intensive_Blue} " Color_Intensive_Blue" | |
color_echo ${Color_Intensive_Purple} " Color_Intensive_Purple" | |
color_echo ${Color_Intensive_Cyan} " Color_Intensive_Cyan" | |
color_echo ${Color_Intensive_White} " Color_Intensive_White" | |
echo "" | |
# Bold High Intensity | |
echo "Bold High Intensity" | |
color_echo ${Color_Bold_Intensive_Black} " Color_Bold_Intensive_Black" | |
color_echo ${Color_Bold_Intensive_Red} " Color_Bold_Intensive_Red" | |
color_echo ${Color_Bold_Intensive_Green} " Color_Bold_Intensive_Green" | |
color_echo ${Color_Bold_Intensive_Yellow} " Color_Bold_Intensive_Yellow" | |
color_echo ${Color_Bold_Intensive_Blue} " Color_Bold_Intensive_Blue" | |
color_echo ${Color_Bold_Intensive_Purple} " Color_Bold_Intensive_Purple" | |
color_echo ${Color_Bold_Intensive_Cyan} " Color_Bold_Intensive_Cyan" | |
color_echo ${Color_Bold_Intensive_White} " Color_Bold_Intensive_White" | |
echo "" | |
# High Intensity backgrounds | |
echo "High Intensity backgrounds" | |
color_echo ${Color_Background_Intensive_Black} " Color_Background_Intensive_Black" | |
color_echo ${Color_Background_Intensive_Red} " Color_Background_Intensive_Red" | |
color_echo ${Color_Background_Intensive_Green} " Color_Background_Intensive_Green" | |
color_echo ${Color_Background_Intensive_Yellow} " Color_Background_Intensive_Yellow" | |
color_echo ${Color_Background_Intensive_Blue} " Color_Background_Intensive_Blue" | |
color_echo ${Color_Background_Intensive_Purple} " Color_Background_Intensive_Purple" | |
color_echo ${Color_Background_Intensive_Cyan} " Color_Background_Intensive_Cyan" | |
color_echo ${Color_Background_Intensive_White} " Color_Background_Intensive_White" | |
echo "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux#answer-28938235