Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: accept-line question
- X-seq: zsh-users 20073
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: accept-line question
- Date: Fri, 3 Apr 2015 01:19:17 +0200
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=McSLHh5eODQ7Ccc8u+pEl9yO9cT0P7LV0p3EZHDB5V4=; b=qaA5YW2oOS1BrGFnOqxW8KHkCeN+1xH1XkujCR8XEGS/dnQqwNsAJSMGq0qQHrUUYS AvOehcocTQ2Tqdi7h0lr5GgiI/aJspvK7SW88l1ZvpkEbz/oDdgHUH5XPdDGUAGvycD8 N7HVPAUAXU3+16PUU/em7jcNdZAnN5cXOplxVspttaShenK8nIprWENVx3I4RxWEv/Ap l4p77mLhrupp7/tS/ajXohrw+dMcsy2lOO3hgiZE3Pnjiwjl6FwoNnD+L4on0IFXOIYD PQLKVc/T7VCPJniagQ48WBWUEKsyfkca0SCcHgOm5DZ8vdZQvQA8bXpY9h17PDtcgrxt 5t1Q==
- In-reply-to: <CAH+w=7Y_Dv4+yGM2FUG3_jE37MN6KvGoyfkTm+A6H7-J3ERNJw@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>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <FF62FDC6-BDD8-4BF3-AD44-F36E834D3B4F@yost.com> <E00A4521-8A4E-486C-BB2E-5D8D80639156@yost.com> <81DADC6E-8DFD-4FB4-9E5D-F3F4CF1EDC07@yost.com> <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@xxxxxxxxxxxxxxxx> wrote:
> On Thu, Apr 2, 2015 at 2:50 PM, Dave Yost <Dave@xxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author