From 1f3a3b41f785d10906678394d13c180657d35210 Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Wed, 18 Mar 2026 09:53:29 -0400 Subject: [PATCH] bash: handle PROMPT_COMMAND ending in a newline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need to handle on more case: when an existing PROMPT_COMMAND ends in a newline, we don't want to append a ; because that already counts as a command separator. We now handle all of these PROMPT_COMMAND cases: - Ends with ; — no ; added - Ends with \n or other whitespace — no ; added - Ends with a command name — ; added as separator See: #11245 --- src/shell-integration/bash/ghostty.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shell-integration/bash/ghostty.bash b/src/shell-integration/bash/ghostty.bash index 4be662ddf..667d7c86b 100644 --- a/src/shell-integration/bash/ghostty.bash +++ b/src/shell-integration/bash/ghostty.bash @@ -303,7 +303,7 @@ if (( BASH_VERSINFO[0] > 4 || (BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 4) ) elif [[ $(builtin declare -p PROMPT_COMMAND 2>/dev/null) == "declare -a "* ]]; then PROMPT_COMMAND+=(__ghostty_hook) else - [[ "${PROMPT_COMMAND}" =~ \;[[:space:]]*$ ]] || PROMPT_COMMAND+=";" + [[ "${PROMPT_COMMAND}" =~ (\;[[:space:]]*|$'\n')$ ]] || PROMPT_COMMAND+=";" PROMPT_COMMAND+=" __ghostty_hook" fi fi