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 30113
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- Cc: "zsh-users@xxxxxxx" <zsh-users@xxxxxxx>, Langbart <Langbart@xxxxxxxxxxxxxx>
- Subject: Re: Foreign Commands Not Appearing in 'history' Array When 'sharehistory' Option is Enabled Until a Command is Entered
- Date: Mon, 25 Nov 2024 12:11:19 -0800
- Archived-at: <https://zsh.org/users/30113>
- In-reply-to: <CAN=4vMrcghV97=X7hV6y9FxzmghU0xWHZHWFR1-PBYK1uDR5Mw@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> <CAH+w=7ZQJFXb5Te1DVxrn7kFUH9jgc=XfrOODKCDLFhRrFEnUQ@mail.gmail.com> <CAN=4vMoM+D99FBnQUds4r5750X9A-6otixayM92_RQnzu7eApA@mail.gmail.com> <CAN=4vMrcghV97=X7hV6y9FxzmghU0xWHZHWFR1-PBYK1uDR5Mw@mail.gmail.com>
On Sat, Nov 23, 2024 at 11:41 PM Roman Perepelitsa
<roman.perepelitsa@xxxxxxxxx> wrote:
>
> 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.
Change the prompt to display %h (history event number) and change the
test function to
function test-history() {
zle up-history
zle -M -- "$HISTNO $#history ${history[${#history}]}"
}
This will demonstrate what's happening: The event shared from
Terminal 2 is being placed in the "current event" slot ($HISTNO) which
is not committed to the full history until a non-empty command is
executed. I believe this in turn is because the test-history widget
is (by program logic) being executed "during editing of the current
event" and consequently that edit is considered unfinished.
I don't have availability to chase this any further any time soon, nor
any clues as to how difficult it would be to alter this behavior in
the face of shared history. The logic about when to commit the
"current event" is pretty deeply ingrained.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author