From: dana <dana@dana.is>
To: zsh <zsh-users@zsh.org>
Cc: Pier Paolo Grassi <pierpaolog@gmail.com>
Subject: Re: populate next comand line from precmd
Date: Tue, 12 Jun 2018 21:55:52 -0500 [thread overview]
Message-ID: <AADDEE74-0DFE-46E6-9702-EDF37A51D1BE@dana.is> (raw)
In-Reply-To: <CAP+y1xB9pAknBm+HLPQVG1yUTP6-rvzbY5L_SQW4i+PBE0-cYw@mail.gmail.com>
On 12 Jun 2018, at 20:44, Pier Paolo Grassi <pierpaolog@gmail.com> 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
next prev parent reply other threads:[~2018-06-13 2:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-13 1:44 Pier Paolo Grassi
2018-06-13 2:55 ` dana [this message]
2018-06-13 8:10 ` Pier Paolo Grassi
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=AADDEE74-0DFE-46E6-9702-EDF37A51D1BE@dana.is \
--to=dana@dana.is \
--cc=pierpaolog@gmail.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).