I tried to set PS1
in the bash_profile as,
.bash_profile
#!/bin/bash
# .....
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
parse_pwd() {
basename $PWD
}
PS1=''$(parse_pwd)''$(parse_git_branch)' $ '
Got the expected output: <project-directory-name> (git-branch-name) $
Problem:
When I change the branch or change project then PS1
details are not updating (i.e. neither the branch name nor the project-directory-name). I had to manually run source ~/.bash_profile
to see those changes in the terminal.
I googled and tried few suggestions like,
Not sure, but is it something to do with my bash? I am currently using zsh,
$ echo $SHELL
/bin/zsh