From d629cb14cbbaade10f3446d3bd078fb8bc078a3f Mon Sep 17 00:00:00 2001 From: xylous Date: Mon, 20 Jun 2022 13:53:23 +0300 Subject: [PATCH] Refactor code determining prompt colour --- gitstatus.plugin.zsh | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/gitstatus.plugin.zsh b/gitstatus.plugin.zsh index 3189884..5d8528f 100755 --- a/gitstatus.plugin.zsh +++ b/gitstatus.plugin.zsh @@ -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 - typeset -g REPLY=$'%F{yellow}' - return 0 - fi - done - typeset -g REPLY=$'%F{green}' - return 0 + if (( $1 > 0 )); then + typeset -g REPLY=$'%F{yellow}' + else + typeset -g REPLY=$'%F{green}' + fi }