From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27591 invoked by alias); 2 Apr 2015 23:19:22 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20073 Received: (qmail 27769 invoked from network); 2 Apr 2015 23:19:21 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 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== MIME-Version: 1.0 X-Received: by 10.107.133.170 with SMTP id p42mr23901607ioi.85.1428016758018; Thu, 02 Apr 2015 16:19:18 -0700 (PDT) In-Reply-To: References: <81DADC6E-8DFD-4FB4-9E5D-F3F4CF1EDC07@yost.com> Date: Fri, 3 Apr 2015 01:19:17 +0200 Message-ID: Subject: Re: accept-line question From: Mikael Magnusson To: Bart Schaefer Cc: Zsh Users Content-Type: text/plain; charset=UTF-8 (don't write your reply up here) On Fri, Apr 3, 2015 at 12:40 AM, Bart Schaefer wrote: > On Thu, Apr 2, 2015 at 2:50 PM, Dave Yost 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