Created
April 14, 2010 21:24
-
-
Save avit/366359 to your computer and use it in GitHub Desktop.
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
# prompt for showing current git branch and dirty state: | |
__git_branch_status() { | |
local b | |
local d | |
if ! [[ $(git status 2> /dev/null) ]]; then | |
return | |
fi | |
if ! b="$(git symbolic-ref HEAD 2>/dev/null)"; then | |
if ! b="$(git describe --exact-match HEAD 2>/dev/null)"; then | |
b="$(git rev-parse 2>/dev/null | cut -c1-7)..." | |
fi | |
fi | |
if [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]]; then | |
d="*" | |
fi | |
echo "(${b##refs/heads/})$d" | |
} | |
export PS1='\u@\h \[\033[1;33m\]\w\[\033[0m\]$(__git_branch_status) $ ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment