Last active
August 29, 2015 14:19
-
-
Save kaityo256/0573714fdce2a44b3f0a to your computer and use it in GitHub Desktop.
.zshrc.git (zsh RPROMPT for git)
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
# put "source .zshrc.git" on your .zshrc | |
autoload -U colors; colors | |
function rprompt-git { | |
local name st color | |
name=`git symbolic-ref HEAD 2> /dev/null | sed -e "s/refs\/heads\///g"` | |
if [[ -z $name ]]; then | |
return | |
fi | |
st=`git status 2> /dev/null` | |
if [[ -n `echo "$st" | grep "^nothing to"` ]]; then | |
color=${fg[green]} | |
elif [[ -n `echo "$st" | grep "^nothing added"` ]]; then | |
color=${fg[yellow]} | |
elif [[ -n `echo "$st" | grep "^# Untracked"` ]]; then | |
color=${fg_bold[red]} | |
else | |
color=${fg[red]} | |
fi | |
echo "(%{$color%}$name%{$reset_color%})" | |
} | |
setopt prompt_subst | |
RPROMPT='`rprompt-git` %{$fg_bold[cyan]%}[%~]%{$reset_color%}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment