1

I'm trying to add the git branch to my Terminal prompt by editing the bash profile but cannot determine why it's not working--haven't been able to apply the answers to any of the other posted questions. Here is what is in my profile now:

if  [ -f $(brew --prefix)/etc/bash_completion.d/git-prompt.sh ]; then
    source $(brew --prefix)/etc/bash_completion.d/git-prompt.sh
    GIT_PS1_SHOWDIRTYSTATE=1
    PS1='\w$(__git_ps1) \n\$ '
fi

For the record, when I ran brew install bash-completion, it did not create git-prompt.sh in the bash_completion.d directory.

wombatdev
  • 11
  • 5
  • 1
    What do you get if you call `__git_ps1` in your shell? – Alberto Zaccagni May 12 '16 at 15:53
  • That's your problem then. Have a look at this answer http://stackoverflow.com/a/12871094/57095 – Alberto Zaccagni May 12 '16 at 21:12
  • 1
    OK, that helped--when I added that line to my bash profile, `__git_ps1` now functions and provides a response, but the branch itself still doesn't appear in my prompt, I have to run the command. Do I need to update the path in the code I posted? Also thanks for the help. – wombatdev May 12 '16 at 21:35
  • Make sure that the body of the `if` gets executed, also you might want to source your `~/.bashrc`. I'm not sure about the branch name, I don't use `__git_ps1`, I've built a custom prompt over the years. – Alberto Zaccagni May 13 '16 at 09:31

0 Answers0