summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Hunter <m@lfurio.us>2026-05-06 02:00:09 -0400
committerMatt Hunter <m@lfurio.us>2026-05-08 02:33:14 -0400
commit5f7de1d0b89d9d5cc6f437061a62e38721077667 (patch)
treea4943d29f5ee1abcbb0e48113bbc573bf88734ac
parent850752caeceff7de4492251706fdc6edd0537d82 (diff)
downloadgit-sonar-5f7de1d0b89d9d5cc6f437061a62e38721077667.tar.gz
git-sonar-5f7de1d0b89d9d5cc6f437061a62e38721077667.zip
Use simpler names for global configuration variables
With a slightly reduced set of config vars, some of which taking on multiple uses, and a recently overhauled script, take the opportunity to simplify some of these variable names. This will also make for shorter lines throughout the script. Signed-off-by: Matt Hunter <m@lfurio.us>
Diffstat (limited to '')
-rwxr-xr-xgit-sonar40
1 files changed, 20 insertions, 20 deletions
diff --git a/git-sonar b/git-sonar
index 02cfb5d..7d71606 100755
--- a/git-sonar
+++ b/git-sonar
@@ -76,25 +76,25 @@ COLOR_RED="\001\\033[1;31m\002"
COLOR_GREEN="\001\\033[1;32m\002"
COLOR_YELLOW="\001\\033[1;33m\002"
COLOR_WHITE="\001\\033[1;37m\002"
-COLOR_DEFAULT="\001\\033[0m\002"
+COLOR_DEF="\001\\033[0m\002"
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_DEFAULT"}"
+BRANCH_COLOR="${GIT_SONAR_BRANCH_COLOR:-"$COLOR_DEF"}"
-COMMIT_ICON_AHEAD="${GIT_SONAR_COMMIT_ICON_AHEAD:-"${COLOR_GREEN}↑"}" # "←"
-COMMIT_ICON_BEHIND="${GIT_SONAR_COMMIT_ICON_BEHIND:-"${COLOR_RED}↓"}" # "→"
-COMMIT_ICON_DIVERGED="${GIT_SONAR_COMMIT_ICON_DIVERGED:-"${COLOR_YELLOW}⇵"}" # "⇄"
+AHEAD_ICON="${GIT_SONAR_AHEAD_ICON:-"${COLOR_GREEN}↑"}" # "←"
+BEHIND_ICON="${GIT_SONAR_BEHIND_ICON:-"${COLOR_RED}↓"}" # "→"
+DIVERGED_ICON="${GIT_SONAR_DIVERGED_ICON:-"${COLOR_YELLOW}⇵"}" # "⇄"
-STATUS_COLOR_STAGED="${GIT_SONAR_STATUS_COLOR_STAGED:-"$COLOR_GREEN"}"
-STATUS_COLOR_UNSTAGED="${GIT_SONAR_STATUS_COLOR_UNSTAGED:-"$COLOR_RED"}"
-STATUS_COLOR_UNMERGED="${GIT_SONAR_STATUS_COLOR_UNMERGED:-"$COLOR_YELLOW"}"
-STATUS_COLOR_UNTRACKED="${GIT_SONAR_STATUS_COLOR_UNTRACKED:-"$COLOR_WHITE"}"
+STAGED_COLOR="${GIT_SONAR_STAGED_COLOR:-"$COLOR_GREEN"}"
+UNSTAGED_COLOR="${GIT_SONAR_UNSTAGED_COLOR:-"$COLOR_RED"}"
+UNMERGED_COLOR="${GIT_SONAR_UNMERGED_COLOR:-"$COLOR_YELLOW"}"
+UNTRACKED_COLOR="${GIT_SONAR_UNTRACKED_COLOR:-"$COLOR_WHITE"}"
PROMPT_COLOR="${GIT_SONAR_PROMPT_COLOR:-"$COLOR_GRAY"}"
-PROMPT_FORMAT="${GIT_SONAR_PROMPT_FORMAT:-" ${PROMPT_COLOR}git:(${COLOR_DEFAULT}%{alert}%{remote: }%{branch}%{ :local}${PROMPT_COLOR})${COLOR_DEFAULT}%{ :stash}%{ :staged}%{ :unmerged}%{ :unstaged}%{ :untracked}"}"
+PROMPT_FORMAT="${GIT_SONAR_PROMPT_FORMAT:-" ${PROMPT_COLOR}git:(${COLOR_DEF}%{alert}%{remote: }%{branch}%{ :local}${PROMPT_COLOR})${COLOR_DEF}%{ :stash}%{ :staged}%{ :unmerged}%{ :unstaged}%{ :untracked}"}"
# Gather current git status and branch information. git porcelain status can
# be especially expensive to compute, so bypass it if the prompt disables status
@@ -134,11 +134,11 @@ print_commit_range() {
behind="$(git rev-list --count "${2}..${1}" 2>/dev/null)" || behind="0"
if [ "$behind" -ne 0 ] && [ "$ahead" -ne 0 ]; then
- printf '%s%b%b%s' "$behind" "$COMMIT_ICON_DIVERGED" "$COLOR_DEFAULT" "$ahead"
+ printf '%s%b%b%s' "$behind" "$DIVERGED_ICON" "$COLOR_DEF" "$ahead"
elif [ "$behind" -ne 0 ]; then
- printf '%s%b%b' "$behind" "$COMMIT_ICON_BEHIND" "$COLOR_DEFAULT"
+ printf '%s%b%b' "$behind" "$BEHIND_ICON" "$COLOR_DEF"
elif [ "$ahead" -ne 0 ]; then
- printf '%b%b%s' "$COMMIT_ICON_AHEAD" "$COLOR_DEFAULT" "$ahead"
+ printf '%b%b%s' "$AHEAD_ICON" "$COLOR_DEF" "$ahead"
fi
fi
}
@@ -149,13 +149,13 @@ element_alert() {
configured_upstream="$(git config --local "branch.${branch_name}.merge")"
if { [ -n "$configured_upstream" ] && [ -z "$upstream_name" ]; } \
|| [ "$precheck_status" -ge 3 ]; then
- printf '%b%b' "$ALERT_ICON" "$COLOR_DEFAULT"
+ printf '%b%b' "$ALERT_ICON" "$COLOR_DEF"
fi
}
element_branch() {
[ -n "$branch_name" ] && branch="$branch_name" || branch="detached@${commit_hash}"
- printf '%b%s%b' "$BRANCH_COLOR" "$branch" "$COLOR_DEFAULT"
+ printf '%b%s%b' "$BRANCH_COLOR" "$branch" "$COLOR_DEF"
}
element_remote() {
@@ -174,7 +174,7 @@ element_local() {
element_stash() {
if [ -n "$opt_stash" ]; then
if cnt="$(git stash list | line_count)"; then
- printf '%s%b%b' "$cnt" "$STASH_ICON" "$COLOR_DEFAULT"
+ printf '%s%b%b' "$cnt" "$STASH_ICON" "$COLOR_DEF"
fi
fi
}
@@ -183,7 +183,7 @@ element_staged() {
if [ -n "$opt_status" ]; then
for x in A M R C D T; do
if cnt="$(status_count "^${x}[^U] ")"; then
- printf '%s%b%s%b' "$cnt" "$STATUS_COLOR_STAGED" "$x" "$COLOR_DEFAULT"
+ printf '%s%b%s%b' "$cnt" "$STAGED_COLOR" "$x" "$COLOR_DEF"
fi
done
fi
@@ -193,7 +193,7 @@ element_unstaged() {
if [ -n "$opt_status" ]; then
for x in M D T; do
if cnt="$(status_count "^[^U]${x} ")"; then
- printf '%s%b%s%b' "$cnt" "$STATUS_COLOR_UNSTAGED" "$x" "$COLOR_DEFAULT"
+ printf '%s%b%s%b' "$cnt" "$UNSTAGED_COLOR" "$x" "$COLOR_DEF"
fi
done
fi
@@ -203,7 +203,7 @@ element_unmerged() {
if [ -n "$opt_status" ]; then
for x in A U D; do
if cnt="$(status_count "^(U${x}|${x}U) ")"; then
- printf '%s%b%s%b' "$cnt" "$STATUS_COLOR_UNMERGED" "$x" "$COLOR_DEFAULT"
+ printf '%s%b%s%b' "$cnt" "$UNMERGED_COLOR" "$x" "$COLOR_DEF"
fi
done
fi
@@ -212,7 +212,7 @@ element_unmerged() {
element_untracked() {
if [ -n "$opt_status" ]; then
if cnt="$(status_count "^\?\? ")"; then
- printf '%s%b?%b' "$cnt" "$STATUS_COLOR_UNTRACKED" "$COLOR_DEFAULT"
+ printf '%s%b?%b' "$cnt" "$UNTRACKED_COLOR" "$COLOR_DEF"
fi
fi
}