Last active
December 26, 2015 16:09
-
-
Save yuuan/7177992 to your computer and use it in GitHub Desktop.
Show branch name only version.
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
# | |
# 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}%}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
詳しくはこちら。
http://www.yuuan.net/blog/index.php?itemid=866