Skip to content

Instantly share code, notes, and snippets.

@yuuan
Last active Dec 26, 2015
Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@yuuan yuuan commented Oct 27, 2013

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