From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1206 invoked from network); 20 May 2005 12:55:21 -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 12:55:21 -0000 Received: (qmail 96002 invoked from network); 20 May 2005 12:55:13 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 20 May 2005 12:55:13 -0000 Received: (qmail 1168 invoked by alias); 20 May 2005 12:55:05 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8874 Received: (qmail 1143 invoked from network); 20 May 2005 12:55:04 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 20 May 2005 12:55:04 -0000 Received: (qmail 94816 invoked from network); 20 May 2005 12:55:04 -0000 Received: from mailhost1.csr.com (HELO MAILSWEEPER01.csr.com) (81.105.217.43) by a.mx.sunsite.dk with SMTP; 20 May 2005 12:54:59 -0000 Received: from exchange03.csr.com (unverified [10.100.137.60]) by MAILSWEEPER01.csr.com (Content Technologies SMTPRS 4.3.12) with ESMTP id for ; Fri, 20 May 2005 13:53:11 +0100 Received: from csr.com ([10.102.144.127]) by exchange03.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Fri, 20 May 2005 13:56:28 +0100 To: zsh-users@sunsite.dk (Zsh users list) Subject: Re: retrieving the results of last command? In-reply-to: <20050520121834.GA32499@let.rug.nl> References: <20050520121834.GA32499@let.rug.nl> Date: Fri, 20 May 2005 13:54:58 +0100 Message-ID: <1049.1116593698@csr.com> From: Peter Stephenson X-OriginalArrivalTime: 20 May 2005 12:56:28.0558 (UTC) FILETIME=[567F8AE0:01C55D3B] X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 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="`fc -ln -1`" > RBUFFER=`$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 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. 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. Normal "insert" widgets append stuff to the left of the cursor rather than replacing RBUFFER. You whould be able to do this: zmodload -i zsh/parameter insert-last-command-output() { LBUFFER+="$(eval $history[$((HISTCMD-1))])" } -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. **********************************************************************