diff --git a/.context.json b/.context.json index d528057..5018b21 100644 --- a/.context.json +++ b/.context.json @@ -432,6 +432,6 @@ "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.", - "Git capsule prefers __git_ps1 and falls back to git symbolic-ref/short hash when git-prompt is unavailable." + "Git capsule prefers __git_ps1 and falls back to git symbolic-ref/short hash when git-prompt is unavailable or returns empty." ] } diff --git a/dotfiles/ps1/ps1.sh b/dotfiles/ps1/ps1.sh index d6e6bbb..fae95c4 100644 --- a/dotfiles/ps1/ps1.sh +++ b/dotfiles/ps1/ps1.sh @@ -169,7 +169,11 @@ __git_capsule() { if declare -F __git_ps1 >/dev/null 2>&1; then has_ps1=1 info="$(__git_ps1 "%s" 2>/dev/null)" - else + if [[ -z "$info" ]]; then + has_ps1=0 + fi + fi + if [[ -z "$info" ]]; then 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