Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: populate next comand line from precmd
- X-seq: zsh-users 23474
- From: dana <dana@xxxxxxx>
- To: zsh <zsh-users@xxxxxxx>
- Subject: Re: populate next comand line from precmd
- Date: Tue, 12 Jun 2018 21:55:52 -0500
- Cc: Pier Paolo Grassi <pierpaolog@xxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana-is.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=UNbwZC4m7YnGFNI6kuY9+XiHM88hEN/KsSUgaKr9RHI=; b=wdgREQnsENaKANVH3/PVZZyGKgs6t3Za9FAFeL6WpipEFF5gtA9LBAQStitcTegHMy uEK7hVOR8rfQGwD0rWlMKGlwfjVS3NPAdVEsGUNH6eWPKWzdwh9gABig7Z1xxYmtTHN9 4dUFr1EsUjt6uKXT1GoZKsw8Q1zMNsslrLeeAqapXJ6L190cv8HEx+Zd/OUkbZoW4oIA Cmuzn0WKrE/O5RlFGKfhHlhZbvuqlmrRIAuaS1tpsHMhygzYA/72iPfmC2phHZGqzusz 3pSkVZnuxpzyGQmNsXjFqAIk/Jgf2fMTUL+N8/KoLlviWGycOuPj1qkK3ZMiIVBtpZyD gHfw==
- In-reply-to: <CAP+y1xB9pAknBm+HLPQVG1yUTP6-rvzbY5L_SQW4i+PBE0-cYw@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAP+y1xB9pAknBm+HLPQVG1yUTP6-rvzbY5L_SQW4i+PBE0-cYw@mail.gmail.com>
On 12 Jun 2018, at 20:44, Pier Paolo Grassi <pierpaolog@xxxxxxxxx> wrote:
>hello, I was wondering if it is somehow possibile to populate the command
>line within the precmd function. What I am trying to achieve is: from a
>normal function (not a zle widget) I would like to set some variable, to be
>read in the precmd function where it is used to populate the next command
>line and also set the cursor position.
Maybe print's -z option would help, at least partially?
-z Push the arguments onto the editing buffer stack, separated by spaces.
Example:
% precmd_insert_args() {
> # Check some variable, whatever
> [[ $history[$((HISTCMD - 1))] == *bar* ]] && {
> print 'Saw bar'
> print -z : inserted args ''
> }
> return 0
> }
% precmd_functions+=( precmd_insert_args )
% : foo # Condition not met
% : bar
Saw bar
% : inserted args <CURSOR HERE>
I say 'partially' because i'm not sure if you can affect the cursor position
(besides inserting things in front of it, obv) from outside of a widget.
dana
Messages sorted by:
Reverse Date,
Date,
Thread,
Author