Filed under: Uncategorized
While trying to work out how the excellent tab completion works for git, I found /etc/bash_completion.d/git which mentions the __git_ps1 command, you can use this to put the current branch in your bash prompt
\u@\h\[\ 033\[00m\]:\[\ 033\[01;33m\]\w\[\ 033\[1;32m\]
$(__git_ps1 " (%s)")\[\ 033\[00m\]$ '
(Remove the space from \ 033, WordPress wouldn’t escape it properly)
The magic bit being
$(__git_ps1 " (%s)")
There are a couple of options you can set too to get it to show you the status of the repo too, see the file above for more info.
Leave a Comment so far
Leave a comment