Skip to content

Instantly share code, notes, and snippets.

@jakebathman jakebathman/.colors
Last active Oct 5, 2018

Embed
What would you like to do?
Terminal colors for your .aliases file (macOS)
# First are the color variables
# Second is a function that will test the colors on your machine (tested on bash and zsh on macOS)
# Some terminals/OS's have weird inconsistencies with the escape codes,
# so google will be your friend if this doesn't work quite right
#
# You can copy/paste these into your .bashrc or similar file
# Don't forget to source the file again or restart your terminal session to apply!
# Normal Colors
export Black='\033[0;30m' # Black
export Red='\033[0;31m' # Red
export Green='\033[0;32m' # Green
export Yellow='\033[0;33m' # Yellow
export Blue='\033[0;34m' # Blue
export Purple='\033[0;35m' # Purple
export Cyan='\033[0;36m' # Cyan
export White='\033[0;37m' # White
# Bold
export BBlack='\033[1;90m' # Black
export BRed='\033[1;91m' # Red
export BGreen='\033[1;92m' # Green
export BYellow='\033[1;93m' # Yellow
export BBlue='\033[1;94m' # Blue
export BPurple='\033[1;95m' # Purple
export BCyan='\033[1;96m' # Cyan
export BWhite='\033[1;97m' # White
# Background
export On_Black='\033[40m' # Black
export On_Red='\033[41m' # Red
export On_Green='\033[42m' # Green
export On_Yellow='\033[43m' # Yellow
export On_Blue='\033[44m' # Blue
export On_Purple='\033[45m' # Purple
export On_Cyan='\033[46m' # Cyan
export On_White='\033[47m' # White
# Background Bold
export On_BBlack='\033[100m' # Black
export On_BRed='\033[101m' # Red
export On_BGreen='\033[102m' # Green
export On_BYellow='\033[103m' # Yellow
export On_BBlue='\033[104m' # Blue
export On_BPurple='\033[105m' # Purple
export On_BCyan='\033[106m' # Cyan
export On_BWhite='\033[107m' # White
export NC="\033[m" # Color Reset
colorcodes() {
T='=^-^='
echo -e "\n Normal BG \033[1;37m\033[40m40m\033[1;0m \033[0;30m\033[41m41m\033[1;0m \033[0;30m\033[42m42m\033[1;0m \033[0;30m\033[43m43m\033[1;0m \033[0;30m\033[44m44m\033[1;0m \033[0;30m\033[45m45m\033[1;0m \033[0;30m\033[46m46m\033[1;0m \033[0;30m\033[47m47m\033[1;0m";
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[m";
done
echo;
done
echo -e "\n High Intensity BG \033[1;37m\033[100m100m\033[1;0m \033[0;30m\033[101m101m\033[1;0m \033[0;30m\033[102m102m\033[1;0m \033[0;30m\033[103m103m\033[1;0m \033[0;30m\033[104m104m\033[1;0m \033[0;30m\033[105m105m\033[1;0m \033[0;30m\033[106m106m\033[1;0m \033[0;30m\033[107m107m\033[1;0m";
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 100m 101m 102m 103m 104m 105m 106m 107m;
do
echo -en "$EINS \033[$FG\033[$BG $T \033[m";
done
echo;
done
echo
echo -e "\n\033[30m\033[107mExample use:\033[m\n"
echo ' escape prefix \\033['
echo ' white bold text . 1;37m'
echo ' escape prefix . . \\033['
echo ' magenta background . . . 45m'
echo ' text . . . . white on magenta'
echo ' escape prefix . . . . . \\033['
echo ' clear formatting . . . . . . m'
echo ' . . . . . . .'
echo ' full command \\033[1;37m\\033[45m white on magenta \\033[m'
echo -e " result \033[1;37m\033[45m white on magenta \033[m"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.