Created
December 16, 2011 00:12
-
-
Save nanha/1483664 to your computer and use it in GitHub Desktop.
git 프롬프트 리눅스 버젼
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
| c_cyan="\033[36m" | |
| c_red="\033[31m" | |
| c_green="\033[32m" | |
| c_pink="\033[35m" | |
| c_sgr0="\033[0m" | |
| parse_branch () | |
| { | |
| if git rev-parse --git-dir >/dev/null 2>&1 | |
| then | |
| branchname="(git:"$(branch_color)$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')${c_sgr0}") " | |
| elif hg prompt >/dev/null 2>&1 | |
| then | |
| branchname="(hg:"$(branch_color)$(hg prompt "{branch}" 2>/dev/null)${c_sgr0}") " | |
| else | |
| return 0 | |
| fi | |
| echo -e $branchname | |
| } | |
| branch_color () | |
| { | |
| if git rev-parse --git-dir >/dev/null 2>&1 | |
| then | |
| color="" | |
| if git diff --quiet 2>/dev/null >&2 | |
| then | |
| gitstatus=$(git status 2>/dev/null| tail -n1) | |
| case "$gitstatus" in | |
| "nothing to commit (working directory clean)" ) color=${c_green};; | |
| * ) color=${c_pink};; | |
| esac | |
| else | |
| color=${c_red} | |
| fi | |
| elif hg prompt >/dev/null 2>&1 | |
| then | |
| color="" | |
| hgstatus=$(hg prompt {status} 2>/dev/null) | |
| case "$hgstatus" in | |
| "!" ) color=${c_red};; | |
| "?" ) color=${c_pink};; | |
| * ) color=${c_green};; | |
| esac | |
| else | |
| return 0 | |
| fi | |
| echo -ne $color | |
| } | |
| export PS1="\u@\h\[${c_red}\]:\W\[${c_sgr0}\] $(parse_branch)\$ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment