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.

link|improve this question

75% accept rate
feedback

1 Answer

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\] '
link|improve this answer
My new hero! Thanks. – Austin Hyde Jul 26 '10 at 20:11
feedback

Your Answer

 
or
required, but never shown

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