-
-
Save floriandejonckheere/b702242666ee74c49d7a to your computer and use it in GitHub Desktop.
Bash colours
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
#!/usr/bin/bash | |
# | |
# c - c070rz 0n ür t3rm1n4l | |
# | |
# Florian Dejonckheere <[email protected]> | |
# | |
if [[ ! $1 || $1 == "-h" ]]; then | |
echo -e "Usage: $0 \e[4mFOREGROUND\e[0m \e[4mBACKGROUND\e[0m \e[4mTEXT\e[0m [ \e[4mDECORATION\e[0m ]" | |
echo | |
echo "Colors: default, white, black, red, green, yellow, blue, purple, cyan, grey" | |
echo "Decorations: d(efault), b(old), (i)talic, (u)nderline, (c)onceal, (s)trikethrough" | |
exit | |
fi | |
declare -A COL | |
COL[white]=1 | |
COL[black]=0 | |
COL[red]=1 | |
COL[green]=2 | |
COL[yellow]=3 | |
COL[blue]=4 | |
COL[purple]=5 | |
COL[cyan]=6 | |
COL[grey]=7 | |
COL[default]= | |
declare -A DEC | |
DEC[i]=3 | |
DEC[u]=4 | |
DEC[c]=8 | |
DEC[s]=9 | |
DEC[d]= | |
FG="3${COL[$1]}m" | |
[[ $4 ]] && case $4 in | |
b) FG="1;${FG}" | |
;; | |
*) D="\e[${DEC[$4]}m" | |
esac | |
BG="4${COL[$2]}m" | |
T="$3" | |
echo -e "\e[${FG}\e[${BG}${D}${T}\e[0m" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment