Skip to content

Instantly share code, notes, and snippets.

@yuuan
Last active December 26, 2015 16:09
Show Gist options
  • Save yuuan/7177992 to your computer and use it in GitHub Desktop.
Save yuuan/7177992 to your computer and use it in GitHub Desktop.
Show branch name only version.
#
# Show branch name in Zsh's right prompt
#
function rprompt-git-current-branch {
local name
if [[ -n `echo "$PWD" 2> /dev/null | grep '/\.git(/.*)?$'` ]]; then
return
else
name=`git rev-parse --abbrev-ref=loose HEAD 2> /dev/null`
if [[ -z $name ]]; then
return
else
echo "$DARK:$YELLOW$name$RED"
fi
fi
}
RED=$'%{\e[1;31m%}'
YELLOW=$'%{\e[0:33m%}'
DARK=$'%{\e[1:30m%}'
RPROMPT=$RED'[%~`get-git-current-branch`]%{${reset_color}%}'
@yuuan
Copy link
Author

yuuan commented Oct 27, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment