|
|
@ -14,31 +14,32 @@ parse_git_dirty () {
|
|
|
|
|
|
|
|
|
|
|
|
# get the status of the working tree
|
|
|
|
# get the status of the working tree
|
|
|
|
git_prompt_status() {
|
|
|
|
git_prompt_status() {
|
|
|
|
INDEX=$(git status --porcelain 2> /dev/null)
|
|
|
|
local indicators line untracked added modified renamed deleted
|
|
|
|
STATUS=""
|
|
|
|
while IFS=$'\n' read line; do
|
|
|
|
if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then
|
|
|
|
if [[ "$line" =~ '^\?\? ' ]]; then
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
|
|
|
|
[[ -n $untracked ]] && continue || untracked='yes'
|
|
|
|
|
|
|
|
indicators="${ZSH_THEME_GIT_PROMPT_UNTRACKED}${indicators}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if $(echo "$INDEX" | grep '^A ' &> /dev/null); then
|
|
|
|
if [[ "$line" =~ '^(((A|M|D|T) )|(AD|AM|AT|MM)) ' ]]; then
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS"
|
|
|
|
[[ -n $added ]] && continue || added='yes'
|
|
|
|
elif $(echo "$INDEX" | grep '^M ' &> /dev/null); then
|
|
|
|
indicators="${ZSH_THEME_GIT_PROMPT_ADDED}${indicators}"
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS"
|
|
|
|
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if $(echo "$INDEX" | grep '^ M ' &> /dev/null); then
|
|
|
|
if [[ "$line" =~ '^(( (M|T))|(AM|AT|MM)) ' ]]; then
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
|
|
|
|
[[ -n $modified ]] && continue || modified='yes'
|
|
|
|
elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then
|
|
|
|
indicators="${ZSH_THEME_GIT_PROMPT_MODIFIED}${indicators}"
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
|
|
|
|
|
|
|
|
elif $(echo "$INDEX" | grep '^ T ' &> /dev/null); then
|
|
|
|
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
|
|
|
|
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if $(echo "$INDEX" | grep '^R ' &> /dev/null); then
|
|
|
|
if [[ "$line" =~ '^R ' ]]; then
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_RENAMED$STATUS"
|
|
|
|
[[ -n $renamed ]] && continue || renamed='yes'
|
|
|
|
|
|
|
|
indicators="${ZSH_THEME_GIT_PROMPT_RENAMED}${indicators}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then
|
|
|
|
if [[ "$line" =~ '^( D|AD) ' ]]; then
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
|
|
|
|
[[ -n $deleted ]] && continue || deleted='yes'
|
|
|
|
|
|
|
|
indicators="${ZSH_THEME_GIT_PROMPT_DELETED}${indicators}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then
|
|
|
|
if [[ "$line" =~ '^UU ' ]]; then
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS"
|
|
|
|
[[ -n $unmerged ]] && continue || unmerged='yes'
|
|
|
|
|
|
|
|
indicators="${ZSH_THEME_GIT_PROMPT_UNMERGED}${indicators}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo $STATUS
|
|
|
|
done < <(git status --porcelain 2> /dev/null)
|
|
|
|
|
|
|
|
echo $indicators
|
|
|
|
}
|
|
|
|
}
|
|
|
|