Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have customized the shell prompt with the following code in my ~/.bash_profile, but there is one quirk left I can't seem to fix:

export PS1="\u:\[\e[32;1;32m\W\e[m\] \$ "

(code is also on github)

This works well, including for long commands. But if I page through the command history with the arrow keys, the prompt will sometimes get a bit "weird". Sometimes it will include a partial command in the prompt or other times the space after the $ will be disappear. Is there something missing from the code above that I should tweak?


share|improve this question
up vote 3 down vote accepted

You didn't close the brackets for the first escape, and add the escape for the second

export PS1="\u:\[\e[32;1;32m\]\W\[\e[m\] \$ "
share|improve this answer
Thank you! Was going cross-eyed trying to get it all to work. :) – Rob Oct 27 '11 at 15:09

Your Answer


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.