diff options
| author | Matt Hunter <m@lfurio.us> | 2026-05-16 18:00:17 -0400 |
|---|---|---|
| committer | Matt Hunter <m@lfurio.us> | 2026-05-16 18:00:17 -0400 |
| commit | 0149e7ec00f08486c672e357ac409dbef0858c13 (patch) | |
| tree | c9f47a36958857fb2b52647fa4dd54a14a5615fd | |
| parent | c607f9c93c0ecb41994a91b4cfebda4efcce7d9e (diff) | |
| download | git-sonar-0149e7ec00f08486c672e357ac409dbef0858c13.tar.gz git-sonar-0149e7ec00f08486c672e357ac409dbef0858c13.zip | |
Allow custom branch color for detached HEAD
Add an additional config variable 'GIT_SONAR_DETACHED_COLOR', which is
used to color the %{branch} element when on a detached HEAD. Both
"branch color" and "detached color" default to uncolored, but may now be
configured independently.
Signed-off-by: Matt Hunter <m@lfurio.us>
| -rwxr-xr-x | git-sonar | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -83,6 +83,7 @@ FETCH_TIME="${GIT_SONAR_FETCH_TIME:-"300"}" ALERT_ICON="${GIT_SONAR_ALERT_ICON:-"${COLOR_YELLOW}⚡"}" STASH_ICON="${GIT_SONAR_STASH_ICON:-"${COLOR_YELLOW}≡"}" BRANCH_COLOR="${GIT_SONAR_BRANCH_COLOR:-"$COLOR_DEF"}" +DETACHED_COLOR="${GIT_SONAR_DETACHED_COLOR:-"$COLOR_DEF"}" STATUS_SEP="${GIT_SONAR_STATUS_SEPARATOR:-" "}" AHEAD_ICON="${GIT_SONAR_AHEAD_ICON:-"${COLOR_GREEN}↑"}" # "←" @@ -140,8 +141,11 @@ element_alert() { } element_branch() { - [ -n "$branch_name" ] && branch="$branch_name" || branch="detached@${commit_hash}" - printf '%b%s%b' "$BRANCH_COLOR" "$branch" "$COLOR_DEF" + if [ -n "$branch_name" ]; then + printf '%b%s%b' "$BRANCH_COLOR" "$branch_name" "$COLOR_DEF" + else + printf '%bdetached@%s%b' "$DETACHED_COLOR" "$commit_hash" "$COLOR_DEF" + fi } element_remote() { |
