Skip to content

Instantly share code, notes, and snippets.

@Kahila
Forked from daytonn/.colors
Created June 27, 2020 04:02
Show Gist options
  • Save Kahila/6b10838fd579a9de4278e34489b02157 to your computer and use it in GitHub Desktop.
Save Kahila/6b10838fd579a9de4278e34489b02157 to your computer and use it in GitHub Desktop.
Bash Color functions
# Colors
end="\033[0m"
black="\033[0;30m"
blackb="\033[1;30m"
white="\033[0;37m"
whiteb="\033[1;37m"
red="\033[0;31m"
redb="\033[1;31m"
green="\033[0;32m"
greenb="\033[1;32m"
yellow="\033[0;33m"
yellowb="\033[1;33m"
blue="\033[0;34m"
blueb="\033[1;34m"
purple="\033[0;35m"
purpleb="\033[1;35m"
lightblue="\033[0;36m"
lightblueb="\033[1;36m"
function black {
echo -e "${black}${1}${end}"
}
function blackb {
echo -e "${blackb}${1}${end}"
}
function white {
echo -e "${white}${1}${end}"
}
function whiteb {
echo -e "${whiteb}${1}${end}"
}
function red {
echo -e "${red}${1}${end}"
}
function redb {
echo -e "${redb}${1}${end}"
}
function green {
echo -e "${green}${1}${end}"
}
function greenb {
echo -e "${greenb}${1}${end}"
}
function yellow {
echo -e "${yellow}${1}${end}"
}
function yellowb {
echo -e "${yellowb}${1}${end}"
}
function blue {
echo -e "${blue}${1}${end}"
}
function blueb {
echo -e "${blueb}${1}${end}"
}
function purple {
echo -e "${purple}${1}${end}"
}
function purpleb {
echo -e "${purpleb}${1}${end}"
}
function lightblue {
echo -e "${lightblue}${1}${end}"
}
function lightblueb {
echo -e "${lightblueb}${1}${end}"
}
function colors {
black "black"
blackb "blackb"
white "white"
whiteb "whiteb"
red "red"
redb "redb"
green "green"
greenb "greenb"
yellow "yellow"
yellowb "yellowb"
blue "blue"
blueb "blueb"
purple "purple"
purpleb "purpleb"
lightblue "lightblue"
lightblueb "lightblueb"
}
function colortest {
if [[ -n "$1" ]]; then
T="$1"
fi
T='gYw' # The test text
echo -e "\n 40m 41m 42m 43m\
44m 45m 46m 47m";
for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' \
'1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' \
' 36m' '1;36m' ' 37m' '1;37m';
do FG=${FGs// /}
echo -en " $FGs \033[$FG $T "
for BG in 40m 41m 42m 43m 44m 45m 46m 47m;
do echo -en "$EINS \033[$FG\033[$BG $T \033[0m";
done
echo;
done
echo
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment