Last active
December 17, 2015 23:29
-
-
Save uu59/5689632 to your computer and use it in GitHub Desktop.
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
autoload -Uz add-zsh-hook | |
add-zsh-hook precmd _update_prompt | |
_update_prompt () { | |
LANG=C vcs_info | |
if [ -z "$vcs_info_msg_0_" ];then | |
RPROMPT="" | |
return 0 | |
fi | |
# 0: main | |
# 1: misc | |
# 2: rebase/merge | |
local prompt="%{%F{${MY_COLOR_PROMPT_GIT_0:-190}%}$(git_clean_or_dirty)%f" | |
prompt+="%F{${MY_COLOR_PROMPT_GIT_0:-190}%}$vcs_info_msg_0_%f" | |
if [ -n "$vcs_info_msg_2_" ]; then | |
prompt+="$prompt %F{${MY_COLOR_PROMPT_GIT_2:-189}%}$vcs_info_msg_2_%f" | |
fi | |
RPROMPT=$prompt | |
} | |
git_clean_or_dirty() { | |
local STATUS="$(git status --porcelain -uall 2> /dev/null)" | |
if [ -z "$STATUS" ];then | |
echo "" | |
else | |
#all=$(echo $STATUS | wc -l ) | |
#tracked=$(git status --porcelain -uno | wc -l) | |
#diff=$(expr $all - $tracked) | |
#echo "%F{009%}✦ $tracked$(if [ $diff -gt 0 ]; then echo " (+$diff)";fi) %f" | |
echo "%F{009%}✦ %f" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment