Here we have yet another script for Git-aware customization of the bash command prompt. Unlike all the other scripts, I wrote this one, so it's better.
- Python 3, version 3.5 or higher
- Git
- bash
-
Save
ps1.py
to your computer somewhere (I put my copy at~/share/ps1.py
) -
Add the following line to the end of your
~/.bashrc
:PROMPT_COMMAND="$PROMPT_COMMAND"'; PS1="$(python3 ~/share/ps1.py "${PS1_GIT:-}")"'
Replace
~/share/ps1.py
with the location you savedps1.py
at as appropriate. -
Open a new shell
-
Enjoy!
-
In case something breaks with the Git integration and prevents you from enjoying, the Git integration can be temporarily disabled by running
PS1_GIT=off
in bash.