From: Bart Schaefer <email@example.com>
Subject: Re: Re-reading history from ZLE
Date: Wed, 24 Aug 2022 14:16:23 -0700 [thread overview]
Message-ID: <CAH+w=7Z2kmpU4vCGwTY3sQofqPpdMFvEzX01sq5+SVMB7as3xw@mail.gmail.com> (raw)
On Wed, Aug 24, 2022 at 8:26 AM martin f krafft <firstname.lastname@example.org> wrote:
> Is there a reason why reset-prompt shouldn't re-initialise ZLE's understanding of history?
History isn't updated until ZLE exits (accept-line, etc.). The
"current event" is not actually in the history, it's treated specially
as a pending entry; almost anything you do with a widget (including
print -s) is effectively part of that pending entry.
There is one exception: The "fc" command updates the history
immediately. So if you rewrite your widget as ...
fc -R =(<<<"echo foo")
zle -M "The last line of history is now 'echo foo'
... then you'll get what you want, including seeing the value of %h
(history number) in your prompt increase by one.
Beware that "fc -R" may ignore lines beginning with ": " because it's
attempting to intuit whether the file is using extended history
format, and if you're adding a multi-line entry you'll want to prefix
all the newlines with backslashes, etc.
prev parent reply other threads:[~2022-08-24 21:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-24 15:20 martin f krafft
2022-08-24 21:16 ` Bart Schaefer [this message]
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:
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
* 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
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).