Create a gist now

Instantly share code, notes, and snippets.

She'll make point five past lightspeed. She may not look like much, but she's got it where it counts, kid. I've made a lot of special modifications myself.
# add in your .bashrc
# I've made the following ajustements:
# - Use of plumbing, that should be faster than git status porcelain.
# - Don't show my repo as dirty if it has files unknown from the index (I always have).
# - Integrated to debian's PS1 (trivial to adapt) and uses standard __git_ps1 from bash_completion
source /usr/local/git/contrib/completion/git-completion.bash
# NOTE: if you notice bash weirdness, disable colors
function __git_dirty {
local dirty RED NO_COLOR
dirty=$(git diff-index --cached --quiet HEAD 2>/dev/null || echo "")
if [ ! -z "$dirty" ]; then
echo "${RED}${dirty}${NO_COLOR}";
dirty=$(git diff-index --quiet HEAD 2>/dev/null || echo "")
[ -z "$dirty" ] && return
echo "${RED}${dirty}${NO_COLOR}";
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$(__git_ps1 "::%s$(__git_dirty)") \$ '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment