Created
July 3, 2012 09:14
-
-
Save tatic0/3038683 to your computer and use it in GitHub Desktop.
colours in bash
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
BaSH color examples |
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 | |
# attribute codes | |
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed | |
# text color codes | |
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white | |
# background color codes | |
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white | |
green='\e[0;32m' | |
blue='\e[0;34m' | |
red='\e[0;31m' | |
endColor='\e[0m' | |
boldGreen='\e[1;32m' | |
boldBlue='\e[1;34m' | |
boldRed='\e[1;31m' | |
endBoldColor='\e[1m' | |
colour=$1 | |
case $colour in | |
blue*) | |
colour=$blue;; | |
red*) | |
colour=$red;; | |
green*) | |
colour=$green;; | |
*) | |
echo -e "Usage: specify ${boldGreen}green${endBoldColor},${boldBlue} blue ${endBoldColor}or ${boldRed}red${endBoldColor}." | |
exit 0 | |
esac | |
echo -e "${colour}Welcome \e[5;32;47m $USER \n${endColor}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment