jimeh / git-aware-prompt

Display current Git branch name in your terminal prompt when in a Git working directory.
Creative Commons Zero v1.0 Universal
2.15k stars 340 forks source link

Prompt shows wrong branch #55

Closed samtstern closed 6 years ago

samtstern commented 6 years ago

Here's my configuration:

export PS1="\u@\h \W \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\n\$ "

Right now in my terminal I see the following prompt:

samstern@samstern-macbookpro firebase-tools (master)
$

But when I run git branch you can see I am not on master:

samstern@samstern-macbookpro firebase-tools (master)

$ git branch
  fix-firestore-delete-escaping
  master
* ss-firestore-delete-bugfix

Any idea what's going on here?

lethosor commented 6 years ago

Have you also set PROMPT_COMMAND?

samtstern commented 6 years ago

No I don't have that set anywhere.

lethosor commented 6 years ago

https://github.com/jimeh/git-aware-prompt/blob/75781b7b7d825f09ed1a9b0eccb2b508da210f49/prompt.sh#L23 You should either source prompt.sh or add that line elsewhere. Without that, git_branch and git_dirty will probably only ever be set once.

samtstern commented 6 years ago

@lethosor that seemed to work, thanks!