From 5641668bc15d3a30232eae2ef104afe88a163688 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 30 Mar 2022 10:44:59 +0530 Subject: [PATCH] Bash integration: Handle existing PROMPT_COMMAND ending with a literal newline --- docs/changelog.rst | 2 ++ shell-integration/bash/kitty.bash | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 0494be1cc..881d49ff5 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -53,6 +53,8 @@ Detailed list of changes - Bash integration: Prevent shell integration code from running twice if user enables both automatic and manual integration +- Bash integration: Handle existing PROMPT_COMMAND ending with a literal newline + - Fix continued lines not having their continued status reset on line feed (:iss:`4837`) - macOS: Allow the New kitty Tab/Window Here services to open multiple selected folders. (:pull:`4848`) diff --git a/shell-integration/bash/kitty.bash b/shell-integration/bash/kitty.bash index 2fa1c0f81..bb0ea08c7 100644 --- a/shell-integration/bash/kitty.bash +++ b/shell-integration/bash/kitty.bash @@ -251,7 +251,7 @@ _ksi_main() { elif [[ $(builtin declare -p PROMPT_COMMAND 2> /dev/null) =~ 'declare -a PROMPT_COMMAND' ]]; then PROMPT_COMMAND+=("$pc") else - PROMPT_COMMAND="${PROMPT_COMMAND%% }" + PROMPT_COMMAND="${PROMPT_COMMAND%%[[:space:]]}" PROMPT_COMMAND="${PROMPT_COMMAND%%;}" PROMPT_COMMAND+="; $pc" fi