From: Roman Perepelitsa <roman.perepelitsa@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: "zsh-users@zsh.org" <zsh-users@zsh.org>,
Langbart <Langbart@protonmail.com>
Subject: Re: Foreign Commands Not Appearing in 'history' Array When 'sharehistory' Option is Enabled Until a Command is Entered
Date: Sun, 24 Nov 2024 08:41:00 +0100 [thread overview]
Message-ID: <CAN=4vMrcghV97=X7hV6y9FxzmghU0xWHZHWFR1-PBYK1uDR5Mw@mail.gmail.com> (raw)
In-Reply-To: <CAN=4vMoM+D99FBnQUds4r5750X9A-6otixayM92_RQnzu7eApA@mail.gmail.com>
On Mon, Oct 28, 2024 at 7:22 PM Roman Perepelitsa
<roman.perepelitsa@gmail.com> wrote:
>
> On Mon, Oct 28, 2024 at 7:15 PM Bart Schaefer <schaefer@brasslantern.com> wrote:
> >
> > I just re-read the OP and I don't find the
> > "widgets that operate on history ... will see the command" part? What
> > have I missed?
>
> I inferred it from this prior interaction:
> https://github.com/romkatv/zsh4humans/issues/329#issuecomment-2439657976.
> This comment and the ones below it. I really need to try this for
> myself and not speculate.
I've tried it myself and can confirm this issue: the history
associative array updates only when you execute a non-empty command;
it does not update when you simply press ENTER, even when
share_history is set.
To reproduce:
1. Run `zsh -f` in two terminals. I'll refer to them as Terminal 1 and
Terminal 2 below.
2. Paste this code into each of the two terminals.
setopt share_history
HISTSIZE=1000
SAVEHIST=1000
HISTFILE=/tmp/hist
zmodload zsh/parameter
function test-history() {
zle up-history
zle -M -- "${history[${#history}]}"
}
zle -N test-history
bindkey '^T' test-history
3. Run `: 1` in Terminal 1.
4. Run `: 2` in Terminal 2.
5. Press ENTER in Terminal 1 without entering a command.
6. Press Ctrl-T in Terminal 1.
Expected:
adam% : 2
: 2
Actual:
adam% : 2
: 1
We can see that `zle up-history` sees the last history event, which
was written by Terminal 2, but `history` does not have it.
Roman
next prev parent reply other threads:[~2024-11-24 7:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-28 15:06 Langbart
2024-10-28 16:42 ` Bart Schaefer
2024-10-28 17:35 ` Roman Perepelitsa
2024-10-28 18:14 ` Bart Schaefer
2024-10-28 18:22 ` Roman Perepelitsa
2024-11-24 7:41 ` Roman Perepelitsa [this message]
2024-11-25 20:11 ` Bart Schaefer
2024-11-26 9:13 ` Mikael Magnusson
2024-11-24 4:47 ` Langbart
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='CAN=4vMrcghV97=X7hV6y9FxzmghU0xWHZHWFR1-PBYK1uDR5Mw@mail.gmail.com' \
--to=roman.perepelitsa@gmail.com \
--cc=Langbart@protonmail.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).