|
|
@ -20,6 +20,74 @@ ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[cyan]%}?"
|
|
|
|
ZSH_THEME_GIT_PROMPT_AHEAD="%{$fg_bold[white]%}↑"
|
|
|
|
ZSH_THEME_GIT_PROMPT_AHEAD="%{$fg_bold[white]%}↑"
|
|
|
|
ZSH_THEME_GIT_PROMPT_BEHIND="%{$fg_bold[white]%}↓"
|
|
|
|
ZSH_THEME_GIT_PROMPT_BEHIND="%{$fg_bold[white]%}↓"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
git_prompt_status () {
|
|
|
|
|
|
|
|
local INDEX STATUS
|
|
|
|
|
|
|
|
INDEX=$(command git status --porcelain -b 2> /dev/null)
|
|
|
|
|
|
|
|
STATUS=""
|
|
|
|
|
|
|
|
if $(echo "$INDEX" | command grep -E '^\?\? ' &> /dev/null)
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if $(echo "$INDEX" | grep '^A ' &> /dev/null)
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS"
|
|
|
|
|
|
|
|
elif $(echo "$INDEX" | grep '^M ' &> /dev/null)
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS"
|
|
|
|
|
|
|
|
elif $(echo "$INDEX" | grep '^MM ' &> /dev/null)
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if $(echo "$INDEX" | grep '^ M ' &> /dev/null)
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
|
|
|
|
|
|
|
|
elif $(echo "$INDEX" | grep '^AM ' &> /dev/null)
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
|
|
|
|
|
|
|
|
elif $(echo "$INDEX" | grep '^MM ' &> /dev/null)
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
|
|
|
|
|
|
|
|
elif $(echo "$INDEX" | grep '^ T ' &> /dev/null)
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if $(echo "$INDEX" | grep '^R ' &> /dev/null)
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_RENAMED$STATUS"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if $(echo "$INDEX" | grep '^ D ' &> /dev/null)
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
|
|
|
|
|
|
|
|
elif $(echo "$INDEX" | grep '^D ' &> /dev/null)
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
|
|
|
|
|
|
|
|
elif $(echo "$INDEX" | grep '^AD ' &> /dev/null)
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if $(command git rev-parse --verify refs/stash >/dev/null 2>&1)
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_STASHED$STATUS"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if $(echo "$INDEX" | grep '^UU ' &> /dev/null)
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if $(echo "$INDEX" | grep '^## [^ ]\+ .*ahead' &> /dev/null)
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_AHEAD$STATUS"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if $(echo "$INDEX" | grep '^## [^ ]\+ .*behind' &> /dev/null)
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_BEHIND$STATUS"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if $(echo "$INDEX" | grep '^## [^ ]\+ .*diverged' &> /dev/null)
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_DIVERGED$STATUS"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo $STATUS
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Evaluate if root user
|
|
|
|
# Evaluate if root user
|
|
|
|
__is_root() {
|
|
|
|
__is_root() {
|
|
|
|
if uname -s | grep -E '^(CYGWIN)|(MINGW)|(MSYS)' 2>&1 >/dev/null; then
|
|
|
|
if uname -s | grep -E '^(CYGWIN)|(MINGW)|(MSYS)' 2>&1 >/dev/null; then
|
|
|
|