Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

With the new version of Snow Leopard, OS X upgraded the bash version to GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0).

Now, my .bashrc sets the following settings:

# Colors
export TERM=xterm-color
export GREP_OPTIONS='--color=auto' GREP_COLOR='1;32'
export CLICOLOR=1 
export LSCOLORS=ExGxFxDxCxHxHxCbCeEbEb

# Setup some colors to use later in interactive shell or scripts
export COLOR_NC='\e[0m' # No Color
export COLOR_WHITE='\e[1;37m'
export COLOR_BLACK='\e[0;30m'
export COLOR_BLUE='\e[0;34m'
export COLOR_LIGHT_BLUE='\e[1;34m'
export COLOR_GREEN='\e[0;32m'
export COLOR_LIGHT_GREEN='\e[1;32m'
export COLOR_CYAN='\e[0;36m'
export COLOR_LIGHT_CYAN='\e[1;36m'
export COLOR_RED='\e[0;31m'
export COLOR_LIGHT_RED='\e[1;31m'
export COLOR_PURPLE='\e[0;35m'
export COLOR_LIGHT_PURPLE='\e[1;35m'
export COLOR_BROWN='\e[0;33m'
export COLOR_YELLOW='\e[1;33m'
export COLOR_GRAY='\e[1;30m'
export COLOR_LIGHT_GRAY='\e[0;37m'

The colours are used later on for output. This used to work in previous version of OSX but not my output is as such: Bash on snow leopard

Some ideas that have not worked.

  • Switching Terminal.app from 64-bit to 32-bit.
share|improve this question
add comment

migrated from stackoverflow.com Oct 12 '09 at 14:59

This question came from our site for professional and enthusiast programmers.

3 Answers

up vote 10 down vote accepted

The answer was actually much simpler. Rather than using \e for the escape character, use \033 instead. So it goes from

export COLOR_NC='\e[0m' # No Color
export COLOR_WHITE='\e[1;37m'
export COLOR_BLACK='\e[0;30m'
export COLOR_BLUE='\e[0;34m'
export COLOR_LIGHT_BLUE='\e[1;34m'
export COLOR_GREEN='\e[0;32m'
export COLOR_LIGHT_GREEN='\e[1;32m'
export COLOR_CYAN='\e[0;36m'
export COLOR_LIGHT_CYAN='\e[1;36m'
export COLOR_RED='\e[0;31m'
export COLOR_LIGHT_RED='\e[1;31m'
export COLOR_PURPLE='\e[0;35m'
export COLOR_LIGHT_PURPLE='\e[1;35m'
export COLOR_BROWN='\e[0;33m'
export COLOR_YELLOW='\e[1;33m'
export COLOR_GRAY='\e[1;30m'
export COLOR_LIGHT_GRAY='\e[0;37m'

to:

# Setup some colors to use later in interactive shell or scripts
export COLOR_NC='\033[0m' # No Color
export COLOR_WHITE='\033[1;37m'
export COLOR_BLACK='\033[0;30m'
export COLOR_BLUE='\033[0;34m'
export COLOR_LIGHT_BLUE='\033[1;34m'
export COLOR_GREEN='\033[0;32m'
export COLOR_LIGHT_GREEN='\033[1;32m'
export COLOR_CYAN='\033[0;36m'
export COLOR_LIGHT_CYAN='\033[1;36m'
export COLOR_RED='\033[0;31m'
export COLOR_LIGHT_RED='\033[1;31m'
export COLOR_PURPLE='\033[0;35m'
export COLOR_LIGHT_PURPLE='\033[1;35m'
export COLOR_BROWN='\033[0;33m'
export COLOR_YELLOW='\033[1;33m'
export COLOR_GRAY='\033[1;30m'
export COLOR_LIGHT_GRAY='\033[0;37m'
share|improve this answer
    
karbassi Thanks so much! I've been looking for a fix all day long. Another solution would be to use zsh instead :) –  Aziz Light Feb 9 '11 at 3:56
    
Glad it helped :) –  karbassi Feb 9 '11 at 3:56
add comment

My Terminal is showing colours.

Try using something like:

PS1='\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;33m\]\w\[\033[00m\]\$ '

And see if the colours appear.

share|improve this answer
add comment

Since the colors are non-printable, using \[ & \] at either end will prevent backspacing and line-wrapping from breaking.

export COLOR_NC='\[\033[0m\]' # No Color
export COLOR_WHITE='\[\033[1;37m\]'
export COLOR_BLACK='\[\033[0;30m\]'
export COLOR_BLUE='\[\033[0;34m\]'
export COLOR_LIGHT_BLUE='\[\033[1;34m\]'
export COLOR_GREEN='\[\033[0;32m\]'
export COLOR_LIGHT_GREEN='\[\033[1;32m\]'
export COLOR_CYAN='\[\033[0;36m\]'
export COLOR_LIGHT_CYAN='\[\033[1;36m\]'
export COLOR_RED='\[\033[0;31m\]'
export COLOR_LIGHT_RED='\[\033[1;31m\]'
export COLOR_PURPLE='\[\033[0;35m\]'
export COLOR_LIGHT_PURPLE='\[\033[1;35m\]'
export COLOR_BROWN='\[\033[0;33m\]'
export COLOR_YELLOW='\[\033[1;33m\]'
export COLOR_GRAY='\[\033[1;30m\]'
export COLOR_LIGHT_GRAY='\[\033[0;37m\]'
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.