Created
June 25, 2011 19:55
-
-
Save ianloic/1046832 to your computer and use it in GitHub Desktop.
Showing the Git module and status
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
setopt prompt_subst | |
autoload colors zsh/terminfo | |
colors | |
function __git_prompt { | |
local DIRTY="%{$fg[yellow]%}" | |
local CLEAN="%{$fg[green]%}" | |
local UNMERGED="%{$fg[red]%}" | |
local RESET="%{$terminfo[sgr0]%}" | |
git rev-parse --git-dir >& /dev/null | |
if [[ $? == 0 ]] | |
then | |
echo -n "[" | |
if [[ `git ls-files -u >& /dev/null` == '' ]] | |
then | |
git diff --quiet >& /dev/null | |
if [[ $? == 1 ]] | |
then | |
echo -n $DIRTY | |
else | |
git diff --cached --quiet >& /dev/null | |
if [[ $? == 1 ]] | |
then | |
echo -n $DIRTY | |
else | |
echo -n $CLEAN | |
fi | |
fi | |
else | |
echo -n $UNMERGED | |
fi | |
echo -n `git branch | grep '* ' | sed 's/..//'` | |
echo -n $RESET | |
echo -n "]" | |
fi | |
} | |
export RPS1='$(__git_prompt)' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment