From 9bfa4553a809d5b9c6c89041b4dc5d49c44220a2 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 11 Feb 2022 06:08:34 +0530 Subject: [PATCH] Shell integration: bash: Fix rendering of multiline prompts with more than two lines Fixes #4681 --- docs/changelog.rst | 2 ++ shell-integration/bash/kitty.bash | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 3ae782a7f..beffa58d3 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -115,6 +115,8 @@ Detailed list of changes - Shell integration: bash: Dont fail if an existing PROMPT_COMMAND ends with a semi-colon (:iss:`4645`) +- Shell integration: bash: Fix rendering of multiline prompts with more than two lines (:iss:`4681`) + - Linux: Fix fontconfig alias not being used if the aliased font is dual spaced instead of monospaced (:iss:`4649`) - macOS: Add an option :opt:`macos_menubar_title_max_length` to control the max length of the window title displayed in the global menubar (:iss:`2132`) diff --git a/shell-integration/bash/kitty.bash b/shell-integration/bash/kitty.bash index 34a88023c..5a20f31f3 100644 --- a/shell-integration/bash/kitty.bash +++ b/shell-integration/bash/kitty.bash @@ -54,9 +54,13 @@ _ksi_main() { PS1="${_ksi_prompt[ps1]}$PS1" if [[ "${_ksi_prompt[mark]}" == "y" ]]; then # bash does not redraw the leading lines in a multiline prompt so - # mark them as secondary prompts + # mark the last line as a secondary prompt. Otherwise on resize the + # lines before the last line will be erased by kitty. PS1=${PS1//\\\[\\e\]133;k;start_secondary_kitty\\a\\\]*end_secondary_kitty\\a\\\]} - PS1=${PS1//"\n"/${_ksi_prompt[secondary_prompt]}} + # the first part removes everything from the last \n onwards + # the second part appends a newline with the secondary marking + # the third part appends everything after the last newline + PS1=${PS1%'\n'*}${_ksi_prompt[secondary_prompt]}${PS1##*'\n'} fi fi if [[ -n "${_ksi_prompt[ps1_suffix]}" ]]; then