__git_ps1 returns (unknown) instead of nothing when I am not in a git directory. That’s a change I’m not too happy with. So I am trying to extend it to get the old behaviour back. So, I added this in my ~/.bashrc and made sure that /etc/bash_completion is sourced before it:
__git_silent_ps1() {
local b='$(__git_ps1 " (%s)")'
if ["$b" != " ((unknown))"]; then
echo -n $b
fi
}
But when I use __git_silent_ps1 in my prompt definition, I get:
-bash: [$(__git_ps1 " (%s)"): command not found
When I just use __git_ps1 in my prompt definition I don’t get that error but it displays the branch. Any idea why I am getting the error and how I can fix it?
Just as one doesn’t write
rmsomefile.txt, one shouldn’t write["$b".