Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: zsh-no-ps2: A plugin that inserts a newline on Enter instead of displaying PS2



On Sun, Nov 12, 2023 at 6:14 AM <zeurkous@xxxxxxxxxxxxxxx> wrote:
>
> On Sun, 12 Nov 2023 14:48:22 +0100, Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx> wrote:
> > tl;dr: zsh-no-ps2 changes the behavior of Enter key to insert a
> > newline instead of going into PS2
> >
> >     git clone https://github.com/romkatv/zsh-no-ps2.git ~/zsh-no-ps2
> >     source ~/zsh-no-ps2/zsh-no-ps2.plugin.zsh
> >
> > Normally, when you press Enter in zsh, one of two things happens:
>
> Might be worth noting that this is also the case with 'Return', which,
> confusingly, produces a carriage return. ('Enter' does only do so by
> later convention; the latter really means "submit data for immediate
> processing", which is a different operation on mainframes).

Interesting as a historical curiosity, but I don't recall zsh ever
running on a mainframe, and typical keyboards have for decades now
produced either '\r' or '\n' pretty much interchangeably for either or
both of Return and Enter, so zsh has always treated the two as
equivalent unless instructed not to.

> > I hate when zsh
> > goes into PS2 because to fix the command most of the time I need to
> > *edit what I've already typed*, which cannot be done.
>
> Interrupt, then recall the command from the history buffer.

This is also what the push-line-or-edit ZLE widget simulates.  I
always rebind ESC-q to push-line-or-edit, leaving ESC-(shift)Q for
push-line.

The drawback to skipping PS2 is that you don't get the helpful hints
about where you are in the syntax tree (by having %_ in the value of
PS2 or RPS2), but as Roman notes in his README.md, you can get back to
that by forcing an accept-line.




Messages sorted by: Reverse Date, Date, Thread, Author