bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multiline editing breaks if the previous output doesn't end in newli


From: Albert Vaca Cintora
Subject: Re: Multiline editing breaks if the previous output doesn't end in newline
Date: Sat, 29 Oct 2022 08:44:26 +0200

On Sat, Oct 29, 2022 at 7:28 AM Koichi Murase <myoga.murase@gmail.com> wrote:
>
> 2022年10月28日(金) 21:24 Albert Vaca Cintora <albertvaka@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 ?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]