Bash color codes - Snow Leopard compatible


/ Published in: Bash
Save to your folder(s)

In Snow Leopard, bash treats colors differently. All the color codes that are escaped with \e won't be recognized. The new escape sequence is \033.

The list below works perfectly in Snow Leopard


Copy this code and paste it in your HTML
  1. # misc
  2. NO_COLOR='\033[0m' #disable any colors
  3. # regular colors
  4. BLACK='\033[0;30m'
  5. RED='\033[0;31m'
  6. GREEN='\033[0;32m'
  7. YELLOW='\033[0;33m'
  8. BLUE='\033[0;34m'
  9. MAGENTA='\033[0;35m'
  10. CYAN='\033[0;36m'
  11. WHITE='\033[0;37m'
  12. # emphasized (bolded) colors
  13. EBLACK='\033[1;30m'
  14. ERED='\033[1;31m'
  15. EGREEN='\033[1;32m'
  16. EYELLOW='\033[1;33m'
  17. EBLUE='\033[1;34m'
  18. EMAGENTA='\033[1;35m'
  19. ECYAN='\033[1;36m'
  20. EWHITE='\033[1;37m'
  21. # underlined colors
  22. UBLACK='\033[4;30m'
  23. URED='\033[4;31m'
  24. UGREEN='\033[4;32m'
  25. UYELLOW='\033[4;33m'
  26. UBLUE='\033[4;34m'
  27. UMAGENTA='\033[4;35m'
  28. UCYAN='\033[4;36m'
  29. UWHITE='\033[4;37m'
  30. # background colors
  31. BBLACK='\033[40m'
  32. BRED='\033[41m'
  33. BGREEN='\033[42m'
  34. BYELLOW='\033[43m'
  35. BBLUE='\033[44m'
  36. BMAGENTA='\033[45m'
  37. BCYAN='\033[46m'
  38. BWHITE='\033[47m'

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.