From 5f9af544230df1bf12627de4d26227557631ad6e Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Sun, 22 Jun 2025 18:00:55 +0200 Subject: [PATCH] giti - Fix branch color and branch name --- giti | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/giti b/giti index db5b610..0270845 100755 --- a/giti +++ b/giti @@ -60,6 +60,12 @@ 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,13 +112,6 @@ 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_COMMIT - echo $BRANCH_VAL - BRANCH_VAL=$(echo $BRANCH_VAL | awk '{print $4}') - echo $BRANCH_VAL - BRANCH_VAL=${BRANCH_VAL::-1} - echo $BRANCH_VAL - else COLOR_BRANCH=$COLOR_BRANCH_BRANCH fi else