I'm using this guide to add git branch name to the PS1 variable. I changed it a little bit, to leave my current prompt theme and to add green background to git branch name.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="$PS1\e[30;48;5;82m$(parse_git_branch)\e[0m \[\033[00m\]"
Looks like everything works, but when I leave the directory, the git branch name stays. And If I run terminal in not git directory, and cd into git, I can't see the name of branch. But when I open another terminal tab, I see it.
I use Guake terminal with Bash shell.