Created
September 13, 2010 23:42
-
-
Save wr0ngway/578267 to your computer and use it in GitHub Desktop.
This file contains 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
# origin of work | |
# http://henrik.nyh.se/2008/12/git-dirty-prompt | |
# http://posterous.timocracy.com/the-trouble-with-bash-colored-prompts-munging | |
function parse_git_dirty { | |
status=`git status 2> /dev/null` | |
bits='' | |
if [[ "${status}" =~ "Changed but not updated" ]]; then | |
bits="${bits}*" | |
fi | |
if [[ "${status}" =~ "Untracked files" ]]; then | |
bits="${bits}?" | |
fi | |
if [[ "${status}" =~ "new file:" ]]; then | |
bits="${bits}+" | |
fi | |
if [[ "${status}" =~ "Your branch is ahead of" ]]; then | |
bits="${bits}^" | |
fi | |
if [[ "${status}" =~ "renamed:" ]]; then | |
bits="${bits}>" | |
fi | |
echo "${bits}" | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/(\1)/" | |
} | |
GREEN='\[\e[01;32m\]' | |
BLUE='\[\e[01;36m\]' | |
MAGENTA='\[\e[01;35m\]' | |
RED='\[\e[01;31m\]' | |
NO_COLOR='\[\e[00m\]' | |
END_COLOR='\[\e[m\]' | |
export PS1="${GREEN}\u${END_COLOR}@${BLUE}\h${END_COLOR} ${MAGENTA}\w${END_COLOR}\$(parse_git_branch)${RED}\$(parse_git_dirty)${END_COLOR}$ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment