I'm basically trying to make my PS1 look like this when in a git repo:
$ ~/Projects/Blah (master):
Or if I'm not in a Git repo, I want it to look like this:
$ ~/Projects/Blah:
This is my current PS1:
export PS1="$ \w \$(__git_ps1): "
It works for the git repo output, but the problem is that if I'm not in a git repo, the output looks like this:
$ ~/Projects/Blah :
I don't really want that space there if it isn't a git repo, is there some way I can specify this in my PS1?
export PS1="$ \w \$(__git_ps1 | sed 's/^ $//'): "
export PS1="$\w\$(__git_ps1):"
that will remove the space, it's not related to the result of__git_ps1
$ ~/Projects/Blah(master):
. I want a space before the parentheses if it is a git repo.PS1
using thePROMPT_COMMAND
bash variable. See: PS1 example\[\033[01;32m\]\w\[\033[01;33m\]$(__git_ps1 " (%s)") \[\033[01;37m\]\$
and that never puts in extra spaces if I'm not in a git folder.