I'm wondering if it's possible to force bash to change it's prompt when I navigate to a certain directory. The specific use case I am looking for is when I navigate into a cloned git repository, I'd like to add which branch I'm working on to the prompt. For example:
user@hostname [~] $ cd git
user@hostname [git] $ cd git-repo #after this, add the branch name
user@hostname [git-repo:develop] $ cd .. #remove branch name as I'm leaving a git repo
user@hostname [git] $
The only thing I've been able to think of is something like this, which I really don't like:
cd_prompt {
cd "$@"
if [ -f .prompt ]; then
source .prompt
fi
}
alias cd=cd_prompt