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 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.",
|
"On macOS, installer is per-user and sources from .bashrc/.bash_profile.",
|
||||||
"Seasonal palettes and contest pack are now documented directly in main.",
|
"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,39 +158,40 @@ __try_source_git_prompt() {
|
|||||||
__try_source_git_prompt >/dev/null 2>&1
|
__try_source_git_prompt >/dev/null 2>&1
|
||||||
|
|
||||||
__git_capsule() {
|
__git_capsule() {
|
||||||
if ! declare -F __git_ps1 >/dev/null 2>&1; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
local info status=""
|
local info status=""
|
||||||
local clean="✨"
|
local clean="✨"
|
||||||
local dirty="🔨"
|
local dirty="🔨"
|
||||||
local staged="📌"
|
local staged="📌"
|
||||||
local untracked="🧷"
|
local untracked="🧷"
|
||||||
local stashed="📦"
|
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
|
[[ -z "$info" ]] && return 0
|
||||||
|
|
||||||
if [[ "$info" == *"*"* ]]; then status+=" $dirty"; fi
|
if (( has_ps1 )); then
|
||||||
if [[ "$info" == *"+"* ]]; then status+=" $staged"; fi
|
if [[ "$info" == *"*"* ]]; then status+=" $dirty"; fi
|
||||||
if [[ "$info" == *"%"* ]]; then status+=" $untracked"; fi
|
if [[ "$info" == *"+"* ]]; then status+=" $staged"; fi
|
||||||
if [[ "$info" == *"$"* ]]; then status+=" $stashed"; fi
|
if [[ "$info" == *"%"* ]]; then status+=" $untracked"; fi
|
||||||
if [[ -z "$status" ]]; then status=" $clean"; fi
|
if [[ "$info" == *"$"* ]]; then status+=" $stashed"; fi
|
||||||
|
if [[ -z "$status" ]]; then status=" $clean"; fi
|
||||||
|
|
||||||
info="${info//\%/}"
|
info="${info//\%/}"
|
||||||
info="${info//\*/}"
|
info="${info//\*/}"
|
||||||
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
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
info="$(printf "%s" "$info" | xargs)"
|
||||||
|
printf " ⟦%s⟧%s" "$info" "$status"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Time-based emoji with seasonal accents (Europe/Oslo)
|
# 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_RIGHT_FG="\[\e[38;5;31m\]"
|
||||||
local H_GIT=""
|
local H_GIT=""
|
||||||
if [[ "$__PS1_GIT" == "1" ]]; then
|
if [[ "$__PS1_GIT" == "1" ]]; then
|
||||||
|
export GIT_PS1_SHOWDIRTYSTATE=1
|
||||||
|
export GIT_PS1_SHOWSTASHSTATE=1
|
||||||
|
export GIT_PS1_SHOWUNTRACKEDFILES=1
|
||||||
H_GIT="$(__git_capsule)"
|
H_GIT="$(__git_capsule)"
|
||||||
fi
|
fi
|
||||||
PS1="\
|
PS1="\
|
||||||
|
|||||||
Reference in New Issue
Block a user