From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6716 invoked from network); 20 May 2005 13:56: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 13:56:21 -0000 Received: (qmail 46256 invoked from network); 20 May 2005 13:56:14 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 20 May 2005 13:56:14 -0000 Received: (qmail 5425 invoked by alias); 20 May 2005 13:56:07 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8876 Received: (qmail 5410 invoked from network); 20 May 2005 13:56:07 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 20 May 2005 13:56:07 -0000 Received: (qmail 45124 invoked from network); 20 May 2005 13:56:07 -0000 Received: from mailhost1.csr.com (HELO MAILSWEEPER01.csr.com) (81.105.217.43) by a.mx.sunsite.dk with SMTP; 20 May 2005 13:56:02 -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 14:54:14 +0100 Received: from news01.csr.com ([10.103.143.38]) by exchange03.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Fri, 20 May 2005 14:57:31 +0100 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.13.1/8.12.11) with ESMTP id j4KDu0mY031150 for ; Fri, 20 May 2005 14:56:00 +0100 Received: from csr.com (pws@localhost) by news01.csr.com (8.13.1/8.13.1/Submit) with ESMTP id j4KDtxMm031147 for ; Fri, 20 May 2005 14:55:59 +0100 Message-Id: <200505201355.j4KDtxMm031147@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: Zsh users list Subject: Re: retrieving the results of last command? In-reply-to: <237967ef05052006445c7578e9@mail.gmail.com> References: <20050520121834.GA32499@let.rug.nl> <1049.1116593698@csr.com> <237967ef05052006445c7578e9@mail.gmail.com> Date: Fri, 20 May 2005 14:55:58 +0100 From: Peter Stephenson X-OriginalArrivalTime: 20 May 2005 13:57:31.0050 (UTC) FILETIME=[DD8378A0:01C55D43] 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 Mikael Magnusson wrote: > On 5/20/05, Peter Stephenson wrote: > > 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. With 4.2, the best way of prompting from within a command line is to use the supplied function read-from-minibuffer. Something like this: insert-last-command-output() { local hist=$history[$((HISTCMD-1))] REPLY autoload -U read-from-minibuffer read-from-minibuffer -k1 "Do you want to execute $hist again y/[n]? " || [[ $REPLY = [yY]* ]] || return 1 LBUFFER+="$(eval $hist)" } -- 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. **********************************************************************