Skip to content

Instantly share code, notes, and snippets.

@catrope
Created November 14, 2014 21:29
Show Gist options
  • Save catrope/309b10c300dd13c40c61 to your computer and use it in GitHub Desktop.
Save catrope/309b10c300dd13c40c61 to your computer and use it in GitHub Desktop.
source /etc/bash_completion.d/git-prompt
GIT_PS1_SHOWDIRTYSTATE='yes'
function git_dirty {
# only tracks modifications, not unknown files needing adds
if [ -z "`git status -s 2> /dev/null | awk '{print $1}' | grep '[ADMTU]'`" ] ; then
return 1
else
return 0
fi
}
function dirty_git_prompt {
git_dirty && __git_ps1
}
function clean_git_prompt {
git_dirty || __git_ps1
}
function git_prompt_if_dirty {
if [[ "$1" =~ .*(\*|\+).* ]]; then
echo "$1"
fi
}
function git_prompt_if_clean {
if [[ "$1" =~ .*(\*|\+).* ]]; then
true
else
echo "$1"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment