From: Mikael Magnusson <mikachu@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: accept-line question
Date: Fri, 3 Apr 2015 01:19:17 +0200 [thread overview]
Message-ID: <CAHYJk3SH_Qn0cZGD57yJ75zW7_gQjUeTy+TYycX642wCZJ9Xsw@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7Y_Dv4+yGM2FUG3_jE37MN6KvGoyfkTm+A6H7-J3ERNJw@mail.gmail.com>
(don't write your reply up here)
On Fri, Apr 3, 2015 at 12:40 AM, Bart Schaefer
<schaefer@brasslantern.com> wrote:
> On Thu, Apr 2, 2015 at 2:50 PM, Dave Yost <Dave@yost.com> wrote:
>> That works.
>>
>> I do want the executed command to be inserted into history.
>>
>> I searched the manual in vain for a way to do that. Any chance you could
>> illuminate further?
>
> Try this:
>
> --- 8< ---
> execute-now() {
> zle -I
> print -S "$BUFFER"
> eval "$BUFFER"
> BUFFER=
> zle -R
> }
> --- 8< ---
>
> Remaining glitches will be that $? / $pipestatus won't be correct when
> redrawing the prompt or executing a subsequent command. I can't
> immediately think of a workaround.
This mostly works, the only caveat is that the commands are executed
in the reverse order:
xxx() {
zle push-input
BUFFER="$1"
zle -U $'\n'
}
x1() { xxx 'echo 1' }
x2() { xxx 'echo 2'; xxx 'echo 3' }
zle -N x{1,2}
Executing x2 will print 3 and then 2 because of how stacks work.
--
Mikael Magnusson
prev parent reply other threads:[~2015-04-02 23:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <FF62FDC6-BDD8-4BF3-AD44-F36E834D3B4F@yost.com>
2015-04-01 15:39 ` Bart Schaefer
[not found] ` <E00A4521-8A4E-486C-BB2E-5D8D80639156@yost.com>
2015-04-02 20:58 ` Mikael Magnusson
2015-04-02 21:30 ` Bart Schaefer
2015-04-02 21:50 ` Dave Yost
2015-04-02 22:40 ` Bart Schaefer
2015-04-02 23:19 ` Mikael Magnusson [this message]
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=CAHYJk3SH_Qn0cZGD57yJ75zW7_gQjUeTy+TYycX642wCZJ9Xsw@mail.gmail.com \
--to=mikachu@gmail.com \
--cc=schaefer@brasslantern.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).