Adds conflicts to git prompt config

master
Jonathan Hodgson 4 years ago
parent 65ddfa3342
commit 83a047a8a3
  1. 14
      shells/zsh/includes/promptconfig.zsh

@ -120,23 +120,29 @@ prompt_git(){
[ -n "$branch" ] && ret=" $branch " [ -n "$branch" ] && ret=" $branch "
[ -n "$tag" ] && ret+=" $tag " [ -n "$tag" ] && ret+=" $tag "
[ -n "$ret" ] || ret="$(git rev-parse --short HEAD 2> /dev/null)" [ -n "$ret" ] || ret="$(git rev-parse --short HEAD 2> /dev/null)"
local repoTopLevel="$(command git rev-parse --show-toplevel 2> /dev/null)"
local untrackedFiles=$(command git ls-files --others --exclude-standard "${repoTopLevel}" 2> /dev/null) local untrackedFiles=$(command git ls-files --others --exclude-standard "${repoTopLevel}" 2> /dev/null)
local modified=$(command git diff --name-only 2> /dev/null) local modified=$(command git diff --name-only 2> /dev/null)
local staged=$(command git diff --staged --name-only 2> /dev/null) local staged=$(command git diff --staged --name-only 2> /dev/null)
local conflicts=$(command git status --porcelain | grep -E '^(.?U|DD|AA)')
local tokens
if [ -n "$untrackedFiles" ]; then if [ -n "$untrackedFiles" ]; then
ret+=" " tokens+=" "
color="orange1" color="orange1"
fi fi
if [ -n "$modified" ]; then if [ -n "$modified" ]; then
ret+=" " tokens+=" "
color="orange1" color="orange1"
fi fi
if [ -n "$staged" ]; then if [ -n "$staged" ]; then
ret+=" " tokens+=" "
color="orange1" color="orange1"
fi fi
if [ -n "$conflicts" ]; then
tokens=" "
color="red1"
fi
ret+="$tokens"
fi fi
ret="$(echo "$ret" | sed -e 's/ *$//')" ret="$(echo "$ret" | sed -e 's/ *$//')"
echo "$ret" echo "$ret"

Loading…
Cancel
Save