Created
October 12, 2012 20:14
-
-
Save xjamundx/3881263 to your computer and use it in GitHub Desktop.
git prompt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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