On Sat, Oct 29, 2022 at 7:28 AM Koichi Murase <myoga.mur...@gmail.com> wrote: > > 2022年10月28日(金) 21:24 Albert Vaca Cintora <albertv...@gmail.com>: > > Description: > > When there's leftover output before the prompt (ie: when the > > previous command output doesn't end in a new line), editing a > > multi-line command from history doesn't correctly display what you > > edit. > > > > [...] > > Option A: If the previous command doesn't end in a newline, > > add a newline manually. This is what most shells do. > > This can be configured by yourself. E.g., > > shopt -s checkwinsize > { ! type -t tput || tput xenl || tput xn; } &>/dev/null; > _prompt_xenl_offset=$? > _prompt_newline() { (:); printf '\e[m%-*s\r\e[K' > "$((COLUMNS-_prompt_xenl_offset))" '[EOF]'; } > PROMPT_COMMAND+=(_prompt_newline)
It would be great if this got fixed in bash itself, but in the meantime this workaround will help, thanks :) I've noted that it creates some artifacts when you resize the terminal after a command that ends without a newline, though. Would you mind explaining the code a bit? Eg: why is "(:);" in there, or why do we need $_prompt_xenl_offset ?