Shell integration: bash: Fix rendering of multiline prompts with more than two lines

Fixes #4681
This commit is contained in:
Kovid Goyal 2022-02-11 06:08:34 +05:30
parent 728eceb620
commit 9bfa4553a8
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 8 additions and 2 deletions

View File

@ -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: 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`) - 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`) - 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`)

View File

@ -54,9 +54,13 @@ _ksi_main() {
PS1="${_ksi_prompt[ps1]}$PS1" PS1="${_ksi_prompt[ps1]}$PS1"
if [[ "${_ksi_prompt[mark]}" == "y" ]]; then if [[ "${_ksi_prompt[mark]}" == "y" ]]; then
# bash does not redraw the leading lines in a multiline prompt so # 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//\\\[\\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
fi fi
if [[ -n "${_ksi_prompt[ps1_suffix]}" ]]; then if [[ -n "${_ksi_prompt[ps1_suffix]}" ]]; then