Skip to content

Instantly share code, notes, and snippets.

@tatic0
Created July 3, 2012 09:14
Show Gist options
  • Save tatic0/3038683 to your computer and use it in GitHub Desktop.
Save tatic0/3038683 to your computer and use it in GitHub Desktop.
colours in bash
BaSH color examples
#!/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