Skip to content

Instantly share code, notes, and snippets.

@kaityo256
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaityo256/0573714fdce2a44b3f0a to your computer and use it in GitHub Desktop.
Save kaityo256/0573714fdce2a44b3f0a to your computer and use it in GitHub Desktop.
.zshrc.git (zsh RPROMPT for git)
# 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