Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Foreign Commands Not Appearing in 'history' Array When 'sharehistory' Option is Enabled Until a Command is Entered
- X-seq: zsh-users 30092
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: "zsh-users@xxxxxxx" <zsh-users@xxxxxxx>
- Cc: Langbart <Langbart@xxxxxxxxxxxxxx>
- Subject: Re: Foreign Commands Not Appearing in 'history' Array When 'sharehistory' Option is Enabled Until a Command is Entered
- Date: Mon, 28 Oct 2024 11:14:46 -0700
- Archived-at: <https://zsh.org/users/30092>
- In-reply-to: <CAN=4vMpYBhtKqh1BVTe01k4ssrsJYU-p8sXC=_kz6xPs_3M6yw@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <mwXIqemfp6p2u5-5ApP-6mjA8aw0SthwcBYnYnkHh13e_46s4ThESPJANCAKlEr2n9VBhClb1JwW_5IiYgljeAv9hJzfculpb9J6QF_lqQY=@protonmail.com> <CAH+w=7ZOwgzV9gb-Zfn-NxWmpa0yPLvevLrApMSYK9S_qAdK-g@mail.gmail.com> <CAN=4vMpYBhtKqh1BVTe01k4ssrsJYU-p8sXC=_kz6xPs_3M6yw@mail.gmail.com>
On Mon, Oct 28, 2024 at 10:35 AM Roman Perepelitsa
<roman.perepelitsa@xxxxxxxxx> wrote:
>
> I believe the OP is saying that after you execute a command in one
> terminal and press ENTER in another terminal, within that second
> terminal all widgets that operate on history, such as
> history-incremental-search-backward, will see the command, but the
> `history` array won't contain it.
That would seem to be pretty nearly impossible, because $history is
populated by calling the same methods that the widgets use, it's not
pre-generated/cached.
However, I notice that the OP is doing this:
printf "%s\t%s\n" "${(kv)history[@]}" | head -5
The left hand side of that pipe is going to be forked off and might
not see the same history list as the parent shell. However, also note
from my "longer answer":
> First, a history position (the "next" number) has already been allocated for expansion of the %h prompt escape, and loading from the shared history would have to somehow fit "above" that.
The history number isn't incremented on an empty command, so this
situation remains. 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?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author