Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: prevent some lines directly coming from the history from being executed
- X-seq: zsh-users 27800
- From: Vincent Lefevre <vincent@xxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: prevent some lines directly coming from the history from being executed
- Date: Wed, 25 May 2022 10:49:20 +0200
- Archived-at: <https://zsh.org/users/27800>
- In-reply-to: <CAH+w=7apO+iFprYnGwTbrrV-jS7WEv1m7uok7NgXpoXGqS_F8w@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- Mail-followup-to: zsh-users@xxxxxxx
- References: <20220524154738.GA35284@cventin.lip.ens-lyon.fr> <CAH+w=7ZXO12Gb7LFGT0US=M=xBdi1XHoMU7t7n4=cbov+EKcNA@mail.gmail.com> <20220525025403.GA97860@zira.vinc17.org> <CAH+w=7apO+iFprYnGwTbrrV-jS7WEv1m7uok7NgXpoXGqS_F8w@mail.gmail.com>
On 2022-05-24 20:59:53 -0700, Bart Schaefer wrote:
> zle-line-finish() {
> if [[ $BUFFER = ${history[$HISTNO]} ]]; then
> local confirm
> read -q confirm"?Confirm: $BUFFER ?"
> [[ $confirm = y ]] || BUFFER=""
> fi
> }
There are some display issues in some cases due to the "Confirm"...
Instead, if the condition is met, is it possible to remain in ZLE
with the current buffer, as if I didn't do accept-line?
(I could set a psvar element so that I could change the prompt to
indicate that this needs confirmation.)
Or perhaps I could change the bindings to use a wrapper around
accept-line (ditto for accept-line-and-down-history).
Something like that (to be completed with pattern matching):
zle -A accept-line real-accept-line
accept-line-wrapper() {
if [[ -z $psvar[3] && $BUFFER = ${history[$HISTNO]} ]]; then
psvar[3]="[Confirm]"
zle reset-prompt
else
psvar[3]=""
zle real-accept-line
fi
}
zle -N accept-line accept-line-wrapper
where $PS1 contains "%3v", and with psvar[3]="" in precmd().
Could there be any issue? Or is there anything to add?
--
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author