Skip to content

Instantly share code, notes, and snippets.

@xjamundx
Created October 12, 2012 20:14
Show Gist options
  • Select an option

  • Save xjamundx/3881263 to your computer and use it in GitHub Desktop.

Select an option

Save xjamundx/3881263 to your computer and use it in GitHub Desktop.
git prompt
git_prompt ()
{
if ! git rev-parse --git-dir > /dev/null 2>&1; then
return 0
fi
git_branch=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')
if git diff --quiet 2>/dev/null >&2; then
git_color="${c_git_clean}"
else
git_color=${c_git_dirty}
fi
echo " [$git_color$git_branch${c_reset}]"
}
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "["${ref#refs/heads/}"] "
}
WHITE="\[\033[1;37m\]"
LIGHTGRAY="\[\033[0;37m\]"
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
LIGHTCYAN="\[\033[0;36m\]"
GREEN="\[\033[0;32m\]"
PS1="$LIGHTGRAY\w $LIGHTCYAN\$(parse_git_branch)$GREEN$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment