Update git plugin with fast dirty check

This commit is contained in:
Jack Drogon 2018-06-14 15:54:55 +08:00
commit 2fb877114e

View file

@ -20,13 +20,23 @@ function parse_git_dirty() {
if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then
FLAGS+='--untracked-files=no' FLAGS+='--untracked-files=no'
fi fi
STATUS=$(command git status ${FLAGS} 2> /dev/null | tail -n1)
if [[ "$(command git config --get oh-my-zsh.fast-dirty-check)" == "1" ]]; then
command git diff --no-ext-diff --quiet --exit-code
if [[ $? == "0" ]]; then
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
else
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
fi fi
else
STATUS=$(command git status ${FLAGS} 2> /dev/null | tail -n1)
if [[ -n $STATUS ]]; then if [[ -n $STATUS ]]; then
echo "$ZSH_THEME_GIT_PROMPT_DIRTY" echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
else else
echo "$ZSH_THEME_GIT_PROMPT_CLEAN" echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
fi fi
fi
fi
} }
# Gets the difference between the local and remote branches # Gets the difference between the local and remote branches