change zshrc git propmt

This commit is contained in:
James Dixon 2022-08-10 03:40:53 -04:00
parent 90f5ecae6f
commit 202f51f9f1

View File

@ -211,12 +211,23 @@ watip() {
# * * * * * * * * * * * *
git_prompt() {
BRANCH=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/*\(.*\)/\1/')
STATUS="$(git status 2> /dev/null)"
if [[ "$?" -ne 0 ]]; then
return
fi
if [ ! -z $BRANCH ]; then
echo -n "%F{yellow}$BRANCH"
if [ ! -z "$(git status --short)" ]; then
echo " %F{red}✗"
fi
if echo "${STATUS}" | grep -c "nothing to commit" &> /dev/null; then echo -n "%F{blue}%s" "="; fi
if echo "${STATUS}" | grep -c "renamed:" &> /dev/null; then echo -n "%F{red}%s" "%"; fi
if echo "${STATUS}" | grep -c "deleted:" &> /dev/null; then echo -n "%F{red}%s" "-"; fi
if echo "${STATUS}" | grep -c "new file:" &> /dev/null; then echo -n "%F{green}%s" "+"; fi
if echo "${STATUS}" | grep -c "branch is ahead:" &> /dev/null; then echo -n "%F{yellow}%s" ">"; fi
if echo "${STATUS}" | grep -c "branch is behind" &> /dev/null; then echo -n "%F{yellow}%s" "<"; fi
if echo "${STATUS}" | grep -c "Untracked files:" &> /dev/null; then echo -n "%F{yellow}%s" "?"; fi
if echo "${STATUS}" | grep -c "modified:" &> /dev/null; then echo -n "%F{yellow}%s" "*"; fi
fi
}
PROMPT='%F{blue}%~$(git_prompt) %F{cyan}%# %F{reset}'
@ -292,6 +303,8 @@ fi
[ -r "$HOME/.config/zshrc" ] && source "$HOME/.config/zshrc"
[ -r "$HOME/.local/zshrc" ] && source "$HOME/.local/zshrc"
[ -d "$HOME/.rbenv" ] && path+=("$HOME/.rbenv/bin") && eval "$(rbenv init - zsh)"
# ZSH syntax highlighting plugin
ZSH_SYNTAX_HIGHLIGHT_PATH="${HOMEBREW_PREFIX}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
[ -f "$ZSH_SYNTAX_HIGHLIGHT_PATH" ] && source $ZSH_SYNTAX_HIGHLIGHT_PATH