From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5350 invoked from network); 20 May 2005 13:44:39 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 20 May 2005 13:44:39 -0000 Received: (qmail 38193 invoked from network); 20 May 2005 13:44:33 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 20 May 2005 13:44:33 -0000 Received: (qmail 29432 invoked by alias); 20 May 2005 13:44:26 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8875 Received: (qmail 29417 invoked from network); 20 May 2005 13:44:26 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 20 May 2005 13:44:26 -0000 Received: (qmail 37154 invoked from network); 20 May 2005 13:44:26 -0000 Received: from zproxy.gmail.com (64.233.162.207) by a.mx.sunsite.dk with SMTP; 20 May 2005 13:44:20 -0000 Received: by zproxy.gmail.com with SMTP id 13so904217nzp for ; Fri, 20 May 2005 06:44:18 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Cu7iyov0fxt34DJ3CgjWSPyWo7Ks+CEM3hpfaxWkewfCseS9FTIIHmejU4EVQuf5IG05wsymd8e0XAGySPErSzsX5eH4W8foMM7h36tnB6Q4K/sENXuWtFDcng1KiFkMO1TRTh2QnxTnhOfs8zx2BXmeWapcLBgTzjwDkchA1/8= Received: by 10.36.72.4 with SMTP id u4mr814305nza; Fri, 20 May 2005 06:44:18 -0700 (PDT) Received: by 10.36.20.7 with HTTP; Fri, 20 May 2005 06:44:18 -0700 (PDT) Message-ID: <237967ef05052006445c7578e9@mail.gmail.com> Date: Fri, 20 May 2005 15:44:18 +0200 From: Mikael Magnusson Reply-To: Mikael Magnusson To: Zsh users list Subject: Re: retrieving the results of last command? Cc: Peter Stephenson In-Reply-To: <1049.1116593698@csr.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <20050520121834.GA32499@let.rug.nl> <1049.1116593698@csr.com> X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.4 required=6.0 tests=AWL,BAYES_00,RCVD_BY_IP autolearn=ham version=3.0.2 X-Spam-Hits: -2.4 On 5/20/05, Peter Stephenson wrote: > Francisco Borges wrote: > > I tried to code a widget to do this, but I this is as far as I got: > > > > insert-last-command-output(){ > > com=3D"`fc -ln -1`" > > RBUFFER=3D`$com` > > } > > zle -N insert-last-command-output > > bindkey "^X^L" insert-last-command-output > > > > #(^X^L was the first free key I could remember...) > > > > but is fails with: > > % locate ipython.el > > /usr/bla/ipython.el > > % insert-last-command-output:1: command not found: locate ipython.el >=20 > You get a complete command line, which needs to be reevaluated. Your > $com is just a string with the line in it, not the command line as > the shell would parse it. >=20 > You can simplify retrieving the command by using the parameter history > from the zsh/parameter library, which contains the history indexed > by the history line number, and the standard parameter HISTCMD which > gives the current history line number. >=20 > Normal "insert" widgets append stuff to the left of the cursor > rather than replacing RBUFFER. >=20 > You whould be able to do this: >=20 > zmodload -i zsh/parameter > insert-last-command-output() { > LBUFFER+=3D"$(eval $history[$((HISTCMD-1))])" > } Hello, Is there a way to ask for confirmation here? It's not always history contains what you expect, for example if you share history and just ran rm -rf . in another terminal, and press this bind you might not be so happy with the outcome. Ie something like zsh: are you sure you want to run $history[$((HISTCMD-1))] again? [yn] Is the read builtin what i want? I never quite got the hang of that one. --=20 Mikael Magnusson