Skip to content

Instantly share code, notes, and snippets.

@levicole
Created November 4, 2011 18:22
Show Gist options
  • Save levicole/1340079 to your computer and use it in GitHub Desktop.
Save levicole/1340079 to your computer and use it in GitHub Desktop.
function parse_git_deleted {
[[ $(git status 2> /dev/null | grep deleted:) != "" ]] && echo "-"
}
function parse_git_added {
[[ $(git status 2> /dev/null | grep "Untracked files:") != "" ]] && echo '+'
}
function parse_git_modified {
[[ $(git status 2> /dev/null | grep modified:) != "" ]] && echo "*"
}
function parse_git_dirty {
echo "$(parse_git_added)$(parse_git_modified)$(parse_git_deleted)"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/<\1$(parse_git_dirty)>/"
}
export PS1="\[\033[01;32m\]\u\[\033[00m\]:\[\033[1;35m\]\W\[\033[0;34m\] \$(parse_git_branch)\[\033[00m\]$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment