From 04c05f61de8b6ecf9edacc614e4c84208720bfaf Mon Sep 17 00:00:00 2001 From: Darren 'Tadgy' Austin Date: Sat, 28 Oct 2023 23:07:34 +0100 Subject: [PATCH] Don't continue prompt if there's no commits. --- .bashrc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.bashrc b/.bashrc index e516973..f74e387 100644 --- a/.bashrc +++ b/.bashrc @@ -51,7 +51,11 @@ __prompt_git_status() { BRANCH="$(git rev-parse --abbrev-ref HEAD 2>/dev/null)" if [[ "$BRANCH" == "HEAD" ]]; then GIT_PROMPT+="?NO COMMITS?" - unset BRANCH + + # Output the prompt and escape early. + # shellcheck disable=SC2059 + printf -- "$1" "$GIT_PROMPT" + return 0 else GIT_PROMPT+="$BRANCH" fi