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 am using this:

$(__git_ps1 '(%s)')

It works however it does not update when I change directories or checkout a new branch. I also have this alias:

alias reload='. ~/.bash_profile'

Sample run:

user@machine:~/dev/rails$cd git_folder/
user@machine:~/dev/rails/git_folder(test)$git checkout master
Switched to branch 'master'

As you can see it is being set correctly but only if I reload bash_profile. I have wasted way to much time on this. I am using bash on snow leopard. Please help!

Edit: You can see my dotfiles on github and the file setting the PS1 here

share|improve this question
up vote 9 down vote accepted

Okay problem solved.

I was doing:

export PS1="$(__git_ps1 '(%s)')"

and I needed to do:

export PS1="\$(__git_ps1 '(%s)')"

You need to escapee the dollar sign otherwise it is just run once and substituted in.

share|improve this answer
awesome, made my day – glebm Nov 27 '10 at 19:52

You probably need to use $PROMPT_COMMAND

share|improve this answer
Thanks. I tried playing with PROMPT_COMMAND but not working with my current setup. You can see the file that makes the setting here: – crayment Mar 19 '10 at 11:06

Note that the latest git moves __git_ps1 out of bash_completion so you need to source it separately. See

share|improve this answer

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.