Fix hawolex git capsule detection
This commit is contained in:
@@ -158,39 +158,40 @@ __try_source_git_prompt() {
|
||||
__try_source_git_prompt >/dev/null 2>&1
|
||||
|
||||
__git_capsule() {
|
||||
if ! declare -F __git_ps1 >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
local info status=""
|
||||
local clean="✨"
|
||||
local dirty="🔨"
|
||||
local staged="📌"
|
||||
local untracked="🧷"
|
||||
local stashed="📦"
|
||||
local has_ps1=0
|
||||
|
||||
if declare -F __git_ps1 >/dev/null 2>&1; then
|
||||
has_ps1=1
|
||||
info="$(__git_ps1 "%s" 2>/dev/null)"
|
||||
else
|
||||
if command -v git >/dev/null 2>&1; then
|
||||
info="$(git symbolic-ref --quiet --short HEAD 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)"
|
||||
fi
|
||||
fi
|
||||
|
||||
info="$(__git_ps1 "%s" 2>/dev/null)"
|
||||
[[ -z "$info" ]] && return 0
|
||||
|
||||
if [[ "$info" == *"*"* ]]; then status+=" $dirty"; fi
|
||||
if [[ "$info" == *"+"* ]]; then status+=" $staged"; fi
|
||||
if [[ "$info" == *"%"* ]]; then status+=" $untracked"; fi
|
||||
if [[ "$info" == *"$"* ]]; then status+=" $stashed"; fi
|
||||
if [[ -z "$status" ]]; then status=" $clean"; fi
|
||||
if (( has_ps1 )); then
|
||||
if [[ "$info" == *"*"* ]]; then status+=" $dirty"; fi
|
||||
if [[ "$info" == *"+"* ]]; then status+=" $staged"; fi
|
||||
if [[ "$info" == *"%"* ]]; then status+=" $untracked"; fi
|
||||
if [[ "$info" == *"$"* ]]; then status+=" $stashed"; fi
|
||||
if [[ -z "$status" ]]; then status=" $clean"; fi
|
||||
|
||||
info="${info//\%/}"
|
||||
info="${info//\*/}"
|
||||
info="${info//\+/}"
|
||||
info="${info//\$/}"
|
||||
info="$(printf "%s" "$info" | xargs)"
|
||||
|
||||
printf " ⟦%s⟧%s" "$info" "$status"
|
||||
}
|
||||
|
||||
__git_capsule() {
|
||||
if declare -F __git_ps1 >/dev/null 2>&1; then
|
||||
__git_ps1 " (%s)" 2>/dev/null
|
||||
info="${info//\%/}"
|
||||
info="${info//\*/}"
|
||||
info="${info//\+/}"
|
||||
info="${info//\$/}"
|
||||
fi
|
||||
|
||||
info="$(printf "%s" "$info" | xargs)"
|
||||
printf " ⟦%s⟧%s" "$info" "$status"
|
||||
}
|
||||
|
||||
# Time-based emoji with seasonal accents (Europe/Oslo)
|
||||
@@ -637,6 +638,9 @@ ${G_Z2_BG}${G_Z2_FG} ${HOST_PART}${PATH_SEP}${G_PATH_FG}${PATH_PART}${G_END_PAD}
|
||||
local H_RIGHT_FG="\[\e[38;5;31m\]"
|
||||
local H_GIT=""
|
||||
if [[ "$__PS1_GIT" == "1" ]]; then
|
||||
export GIT_PS1_SHOWDIRTYSTATE=1
|
||||
export GIT_PS1_SHOWSTASHSTATE=1
|
||||
export GIT_PS1_SHOWUNTRACKEDFILES=1
|
||||
H_GIT="$(__git_capsule)"
|
||||
fi
|
||||
PS1="\
|
||||
|
||||
Reference in New Issue
Block a user