From 8e3ee44ea4f54c64ad8874709960373c67527ab0 Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Sun, 22 Jun 2025 22:02:05 +0200 Subject: [PATCH] giti - branch color fix --- giti | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/giti b/giti index 0270845..158a31b 100755 --- a/giti +++ b/giti @@ -60,12 +60,6 @@ GIT_URL="$(LANGUAGE='en_US.UTF-8 git' git config --get remote.origin.url 2> /dev GIT_STATUS="$(LANGUAGE='en_US.UTF-8 git' git status -sb 2> /dev/null)" GIT_FILES="$(LANGUAGE='en_US.UTF-8 git' git status -s 2> /dev/null)" BRANCH_VAL="$(LANGUAGE='en_US.UTF-8 git' git branch 2> /dev/null | sed --quiet 's/* \(.*\)/\1/p')" -if [[ $BRANCH_VAL == *"HEAD detached at"* ]]; then - COLOR_BRANCH=$COLOR_BRANCH_COMMIT - BRANCH_VAL=$(echo $BRANCH_VAL | awk '{print $4}') - BRANCH_VAL=${BRANCH_VAL::-1} - COLOR_BRANCH_BRANCH=$COLOR_BRANCH_COMMIT -fi STASH_VAL=$(LANGUAGE='en_US.UTF-8 git' git stash list 2> /dev/null | wc -l) # decision for git output (path is repository) @@ -106,16 +100,20 @@ if [[ ! -z "$GIT_FILES" ]]; then fi # GIT STATUS COLOR ################################################################################ +if [[ $BRANCH_VAL == "master" || $BRANCH_VAL == "main" ]]; then + COLOR_BRANCH=$COLOR_BRANCH_CLEAN +elif [[ $BRANCH_VAL == *"HEAD detached at"* ]]; then + COLOR_BRANCH=$COLOR_BRANCH_COMMIT + BRANCH_VAL=$(echo $BRANCH_VAL | awk '{print $4}') + BRANCH_VAL=${BRANCH_VAL::-1} +else + COLOR_BRANCH=$COLOR_BRANCH_BRANCH +fi + if [[ $COMMITED_VAL > 0 || $CHANGED_VAL > 0 ]]; then COLOR_BRANCH="$COLOR_BRANCH_CHANGED" elif [[ $BEHIND_VAL > 0 || $AHEAD_VAL > 0 || $NEW_VAL > 0 ]]; then COLOR_BRANCH="$COLOR_BRANCH_OUTDATED" -elif [[ $BRANCH_VAL != "master" && $BRANCH_VAL != "main" ]]; then - if [[ $BRANCH_VAL == *"HEAD detached at"* ]]; then - COLOR_BRANCH=$COLOR_BRANCH_BRANCH - fi -else - COLOR_BRANCH=$COLOR_BRANCH_CLEAN fi # GIT GATHERING ###################################################################################