From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23992 invoked from network); 22 Sep 2006 14:58:58 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.5 (2006-08-29) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 22 Sep 2006 14:58:58 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 81944 invoked from network); 22 Sep 2006 14:58:51 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 22 Sep 2006 14:58:51 -0000 Received: (qmail 11227 invoked by alias); 22 Sep 2006 14:58:43 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10755 Received: (qmail 11218 invoked from network); 22 Sep 2006 14:58:43 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 22 Sep 2006 14:58:43 -0000 Received: (qmail 80811 invoked from network); 22 Sep 2006 14:58:43 -0000 Received: from cluster-d.mailcontrol.com (217.69.20.190) by a.mx.sunsite.dk with SMTP; 22 Sep 2006 14:58:41 -0000 Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly22d.srv.mailcontrol.com (MailControl) with ESMTP id k8MEvno2013947 for ; Fri, 22 Sep 2006 15:58:39 +0100 Received: from news01.csr.com ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.1830); Fri, 22 Sep 2006 15:57:10 +0100 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.13.7/8.13.4) with ESMTP id k8MEvAVh028572 for ; Fri, 22 Sep 2006 15:57:10 +0100 Received: from csr.com (pws@localhost) by news01.csr.com (8.13.7/8.13.7/Submit) with ESMTP id k8MEvAhC028569 for ; Fri, 22 Sep 2006 15:57:10 +0100 Message-Id: <200609221457.k8MEvAhC028569@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: zsh-users@sunsite.dk Subject: Re: Returning last parameter of a history command In-reply-to: References: Comments: In-reply-to zzapper message dated "Fri, 22 Sep 2006 13:59:00 -0000." Date: Fri, 22 Sep 2006 15:57:09 +0100 From: Peter Stephenson X-OriginalArrivalTime: 22 Sep 2006 14:57:10.0217 (UTC) FILETIME=[61468390:01C6DE57] Content-Type: text/plain MIME-Version: 1.0 X-Scanned-By: MailControl A-07-04-01 (www.mailcontrol.com) on 10.68.0.132 zzapper wrote: > Hi > > how should this done in zsh-speak > > history -n -1|sed 's/^.* // > > Where the sed returns the last parameter zmodload -i zsh/parameter print ${${(z)history[$((HISTCMD-1))]}[-1]} Adjust the line number as necessary: it's $((HISTCMD-1)) when you're getting the previous line at the prompt but it depends where you are relative to the line being updated. Experiment. Note that $history is an associative array; you need to get the line number in the key exactly right. -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php