Skip to content

Instantly share code, notes, and snippets.

@cowboyrushforth
Created December 9, 2010 21:45
Show Gist options
  • Save cowboyrushforth/735384 to your computer and use it in GitHub Desktop.
Save cowboyrushforth/735384 to your computer and use it in GitHub Desktop.
COLOR_YELLOW="\[\e[33;40m\]"
COLOR_RED="\[\e[31;40m\]"
COLOR_GREEN="\[\e[32;40m\]"
COLOR_BLUE="\[\e[34;40m\]"
COLOR_NONE="\[\e[0m\]"
COLOR_NONEP="\[\e[38;40m\]"
git_dirty_flag() {
git status 2> /dev/null | grep -c : | awk '{if ($1 > 0) print "⚡"}'
}
parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \1/'
}
prompt_func() {
previous_return_value=$?;
prompt="${COLOR_GREEN}❨\h) ${COLOR_BLUE}\w${COLOR_GREEN}$(parse_git_branch)${COLOR_YELLOW}$(git_dirty_flag)${COLOR_NONEP} "
if test $previous_return_value -eq 0
then
PS1="${prompt}${COLOR_NONEP}➔ ${COLOR_NONE}"
else
PS1="${prompt}${COLOR_RED}➔ ${COLOR_NONE}"
fi
}
PROMPT_COMMAND=prompt_func
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment