Skip to content

Instantly share code, notes, and snippets.

@mcspring
Last active October 8, 2015 11:27
Show Gist options
  • Save mcspring/3324955 to your computer and use it in GitHub Desktop.
Save mcspring/3324955 to your computer and use it in GitHub Desktop.
git shell prompt
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
NO_COLOR="\[\033[0m\]"
PS1="\u@\w$YELLOW\$(parse_git_branch)$NO_COLOR\$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment