Skip to content

Instantly share code, notes, and snippets.

@mbildner
Last active August 29, 2015 14:05
Show Gist options
  • Save mbildner/c0486dec166444bf366a to your computer and use it in GitHub Desktop.
Save mbildner/c0486dec166444bf366a to your computer and use it in GitHub Desktop.
clean/dirty branch name
LIGHT_GRAY="\[\033[0;37m\]"; BLUE="\[\033[1;36m\]"; RED="\[\033[0;31m\]"; LIGHT_RED="\[\033[1;31m\]";
GREEN="\[\033[0;32m\]"; WHITE="\[\033[1;37m\]"; LIGHT_GRAY="\[\033[0;37m\]"; YELLOW="\[\033[1;33m\]";
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \(\1\)/';
}
function parse_git_status {
git status 2> /dev/null | grep 'working directory clean' | wc -l;
}
function check_git_changes {
# tput setaf 1 = RED, tput setaf 2 = GREEN
[ `parse_git_status` -ne 1 ] && tput setaf 1 || tput setaf 2
}
export PS1="$YELLOW\w\[\$(check_git_changes)\]\$(parse_git_branch)$LIGHT_GRAY $ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment