jngacayan
jngacayan

Reputation: 75

Git Bash Missing Branch Name and $ in line

I am having a weird issue with git bash. I just installed git and whenever I open git bash in my local repository, the branch name is missing and the $ symbol before each line is also missing:

enter image description here

The image above shows my issue. That directory is already the local repository yet it is not showing the branch name beside it and the line does not start with the $ symbol.

My PS1 is set to:

[\e]0;\w\a]\n[\e[32m]\u@\h [\e[35m]$MSYSTEM[\e[0m] [\e[33m]\w[\e[0m]\n

I can still do git commands but I am not really comfortable with this.

I hope someone can help me.

Thanks!

Upvotes: 1

Views: 2212

Answers (2)

paxdiablo
paxdiablo

Reputation: 881623

Your PS1 variable has neither a $(__git_ps1) nor a closing $ in it. The former is what gives you the branch name, the latter will give you your $ at the end.

For example, this one is what I have set:

\[\e]0;git__${PWD//[^[:ascii:]]/?}\007\]\n\[\e[32m\]\u \[\e[33m\]\w$(__git_ps1)\[\e[0m\]\n>

For your particular needs, you may want to look at starting with:

PS1='\e]0;\w\n\e[32m\u@\h \e[35m$MSYSTEM\e[0m \e[33m\w\e[0m$(__git_ps1)\n$ '

and working from there. That gives me:

enter image description here

Upvotes: 2

rlee827
rlee827

Reputation: 1873

Previous versions of Git Bash had a different $PS1 which included branch information and the dollar sign. The default $PS1 that includes the dollar sign is below:

PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[35m\]$MSYSTEM\[\e[0m\] \[\e[33m\]\w\[\e[0m\]\n\$ '

Instructions for adding the branch name can be found from this file in the official Git development repository.

Upvotes: 2

Related Questions