zsh-users
 help / color / mirror / code / Atom feed
From: Pier Paolo Grassi <pierpaolog@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh-Users List <zsh-users@zsh.org>
Subject: Re: commit to history
Date: Sat, 28 Aug 2021 21:34:10 +0200	[thread overview]
Message-ID: <CAP+y1xD8PWO_X+0eL4C-c1Nrywpbh3aopkHW+9AX_GF-+qRW5w@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7ae2r+M6R=dJy6Qz6g3U6VKhvU8S1-ehsZ+OoWhHUni5A@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1902 bytes --]

It seems that zle send-break commits to history the content of PREBUFFER
when used from PS2, does this makes sense?
I replicated it with:

echo abc\<enter>
> def<ctrl-G>

now the first item in the history is:
: 1630178520:0;E qwe\

this is wrong, due to the \ at the end of the row that will make the
subsequent row treated as part of a multi-line construct but it is not,
only the first line has been inserted in the history. in my case the
following line in .zsh_history is:
: 1630178638:0;tail -n 1 ~/.zsh_history

if I insert more lines before pressing ctrl-g just the last one is missing:

echo ab\<enter>
> bc\<enter>
> de<ctrl-G>

tail -n 3 zsh-history
: 1630178860:0;echo ab\\
bc\
: 1630178870:0;tail -n 3 ~/.zsh_history

this may be due to my very old zsh (5.1.1)

Pier Paolo Grassi


Il giorno ven 27 ago 2021 alle ore 23:59 Bart Schaefer <
schaefer@brasslantern.com> ha scritto:

> On Fri, Aug 27, 2021 at 2:15 PM Pier Paolo Grassi <pierpaolog@gmail.com>
> wrote:
> >
> > the send-break widget returns a status code 1, and since I have a precmd
> that displays the last status code, I was wondering if it is in some way
> possibile to suppress that return status.
>
> The short answer is no, there is not.  There was a long thread about
> this on zsh-workers earlier this year, search "curious incident of the
> feep".
>
> As written your widget discards multi-line structures if invoked at
> the PS2 prompt.  If that's intentional you can replace with:
>
> commit_to_history() {
>   print -rs -- ${(q)${(z)BUFFER}}
>   BUFFER=''
>   if [[ -n $PREBUFFER ]]
>   then zle accept-line
>   else zle send-break
>   fi
> }
>
> If you would prefer to capture multi-line structure at PS2,
>
> commit_to_history() {
>   local fullbuffer="$PREBUFFER$BUFFER"
>   print -rs -- ${(q)${(z)fullbuffer}}
>   BUFFER=''
>   if [[ -n $PREBUFFER ]]
>   then zle accept-line
>   else zle send-break
>   fi
> }
>

[-- Attachment #2: Type: text/html, Size: 2935 bytes --]

      reply	other threads:[~2021-08-28 19:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-27 21:14 Pier Paolo Grassi
2021-08-27 21:59 ` Bart Schaefer
2021-08-28 19:34   ` Pier Paolo Grassi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAP+y1xD8PWO_X+0eL4C-c1Nrywpbh3aopkHW+9AX_GF-+qRW5w@mail.gmail.com \
    --to=pierpaolog@gmail.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).