I'm trying to make a small tool (maybe it already exist) to help working with repositories and branches from the terminal.
Basically the idea is to have the name of the branch in the prompt (similar to virtual environments, which also show the current environment in the prompt).
The following command just extracts the name of the branch I'm currently in.
git branch | grep "*" | cut -c3- Including this in my .bashrc file to modify PS1 works, however only changes the prompt when the console is open.
I want to update the prompt everytime I change the folder cd my_folder, cd .. so if I go to another repository, it updates the branch.
So I created an alias for cd, which now appends this small script after executing the cd.
However if I use git to change the branch since I'm not changing the folder the prompt is not inmediately updated.
I can also create an alias for git but I have the impression I'm changing too much things and maybe this is something that already exists.
To avoid reinventing the wheel, does this already exist? Is it a good idea to use it?
Thanks


