Refactor code determining prompt colour

This commit is contained in:
xylous 2022-06-20 13:53:23 +03:00
parent 816cd8a54b
commit d629cb14cb
No known key found for this signature in database
GPG Key ID: A9E6DA43F5E78D24

View File

@ -32,7 +32,7 @@ function gitstatus()
&& git_local_remote_diffs "$branch" "$remote" \
&& local commit_diffs="$REPLY"
git_determine_color ${modified} ${staged} ${deleted} ${untracked}
git_determine_color $((modified + staged + deleted + untracked))
local color="${REPLY}"
(( modified > 0 )) \
@ -168,12 +168,9 @@ function git_local_remote_diffs()
###
function git_determine_color()
{
for i in "$@"; do
if (( $i > 0 )); then
if (( $1 > 0 )); then
typeset -g REPLY=$'%F{yellow}'
return 0
fi
done
else
typeset -g REPLY=$'%F{green}'
return 0
fi
}