I'm adding this code
if [ -f ~/.git-prompt.sh ]; then
source ~/.git-prompt.sh
export PS1='\[\033[01;34m\]\w\[\033[00m\] $(__git_ps1 "(%s)"): '
fi
to get this result.
~/apps/project-with-git-repo (develop):
But when I go to other folders without a git repository, I see this result.
~/apps/folder-without-git-repo (BARE:master):
How do I get rid of (BARE:master)? For example, if there is no repository, then do not output git at all
~/.git-prompt.sh
... which you haven't shown. If you really don't want to change that, you can always just use a${//}
substitution orsed
to replace that string ... but you also haven't said what you want it replaced with.PS1
appropriately based on whether you're in a repository in the first place. That is, you must test: "am I in a Git repo" before you attempt to insert the$(__git_ps1 ...)
output.