diff --git a/shell-integration/kitty.fish b/shell-integration/kitty.fish index 34738c7f8..e54ff4346 100644 --- a/shell-integration/kitty.fish +++ b/shell-integration/kitty.fish @@ -60,8 +60,13 @@ function _ksi_main function _ksi_end_prompt set --local cmd_status "$status" - set --local op (_ksi_original_fish_prompt | string collect) # trim trailing newlines to mimic fish behavior - printf "%s" "$op" + # fish trims one trailing newline from the output of fish_prompt, so + # we need to do the same. See https://github.com/kovidgoyal/kitty/issues/4032 + set --local op (_ksi_original_fish_prompt) # op is an array because fish splits on newlines in command substitution + if set -q op[2] + printf '%s\n' $op[1..-2] # print all but last element of array, each followed by a new line + end + printf '%s' $op[-1] # print the last component without a newline set --global _ksi_prompt_state "prompt_end" _ksi_mark "B" return "$cmd_status" # preserve the value of $status