Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 followed the directions outlined by Steve Losh to colorize and format my bash prompt, however, the prompt doesn't update.

My export PS1 line looks like this:

export PS1="\n\[$txtgrn\]\w\[$txtrst\]$(hg_in_repo)\[$txtylw\]$(hg_branch)\[$txtrst\]$(hg_dirty)\n\[$txtcyn\]\$\[$txtrst\] "

Yes, all those $txtxxx's are defined.

Everything works as expected, both inside and out of a repository, but I have to constantly source ~/.bash_profile to get the prompt to update.

Am I missing something? Is there a way to get it to update every time I execute a command, like he demonstrates in the screenshot further down the page?

I am using Mac OSX 10.5 (Leopard), with Terminal and/or iTerm.

share|improve this question
up vote 1 down vote accepted

You need to escape the dollar signs so the command substitution isn't evaluated until the prompt is issued:

export PS1="\n\[$txtgrn\]\w\[$txtrst\]\$(hg_in_repo)\[$txtylw\]\$(hg_branch)\[$txtrst\]\$(hg_dirty)\n\[$txtcyn\]\$\[$txtrst\] "

Or, if you notice on that page, he uses single quotes which also prevents expansion of the command substitution until the prompt is issued:

export PS1='\n\[$txtgrn\]\w\[$txtrst\]$(hg_in_repo)\[$txtylw\]$(hg_branch)\[$txtrst\]$(hg_dirty)\n\[$txtcyn\]\$\[$txtrst\] '
share|improve this answer
My new hero! Thanks. – Austin Hyde Jul 26 '10 at 20:11

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.