Fix hawolex git capsule detection
This commit is contained in:
@@ -431,6 +431,7 @@
|
||||
"On Linux, installer affects all users by writing to /etc/profile.d and sourcing from /etc/bash.bashrc.",
|
||||
"On macOS, installer is per-user and sources from .bashrc/.bash_profile.",
|
||||
"Seasonal palettes and contest pack are now documented directly in main.",
|
||||
"README uses images/bash-pallete.png."
|
||||
"README uses images/bash-pallete.png.",
|
||||
"Git capsule prefers __git_ps1 and falls back to git symbolic-ref/short hash when git-prompt is unavailable."
|
||||
]
|
||||
}
|
||||
|
||||
@@ -158,20 +158,26 @@ __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
|
||||
|
||||
[[ -z "$info" ]] && return 0
|
||||
|
||||
if (( has_ps1 )); then
|
||||
if [[ "$info" == *"*"* ]]; then status+=" $dirty"; fi
|
||||
if [[ "$info" == *"+"* ]]; then status+=" $staged"; fi
|
||||
if [[ "$info" == *"%"* ]]; then status+=" $untracked"; fi
|
||||
@@ -182,15 +188,10 @@ __git_capsule() {
|
||||
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
|
||||
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