From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22234 invoked from network); 29 Apr 2004 11:43:59 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (qmailr@130.225.247.86) by ns1.primenet.com.au with SMTP; 29 Apr 2004 11:43:59 -0000 Received: (qmail 28524 invoked from network); 29 Apr 2004 11:43:42 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 29 Apr 2004 11:43:42 -0000 Received: (qmail 10556 invoked by alias); 29 Apr 2004 11:43:31 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7419 Received: (qmail 10540 invoked from network); 29 Apr 2004 11:43:30 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 29 Apr 2004 11:43:30 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [130.225.247.86] by sunsite.dk (MessageWall 1.0.8) with SMTP; 29 Apr 2004 11:43:30 -0000 Received: (qmail 27524 invoked from network); 29 Apr 2004 11:43:29 -0000 Received: from lhuumrelay3.lnd.ops.eu.uu.net (62.189.58.19) by a.mx.sunsite.dk with SMTP; 29 Apr 2004 11:43:27 -0000 Received: from MAILSWEEPER01.csr.com (mailhost1.csr.com [62.189.183.235]) by lhuumrelay3.lnd.ops.eu.uu.net (8.11.0/8.11.0) with ESMTP id i3TBh0v01815 for ; Thu, 29 Apr 2004 11:43:00 GMT Received: from EXCHANGE02.csr.com (unverified [192.168.137.45]) by MAILSWEEPER01.csr.com (Content Technologies SMTPRS 4.3.12) with ESMTP id for ; Thu, 29 Apr 2004 12:42:32 +0100 Received: from csr.com ([192.168.144.127]) by EXCHANGE02.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Thu, 29 Apr 2004 12:44:03 +0100 To: zsh-users@sunsite.dk Subject: Re: Completion of CLI parameters In-reply-to: "zzapper"'s message of "Thu, 29 Apr 2004 09:35:31 BST." <4me190pohevfcnoecm43f7ab9cclh3233g@4ax.com> Date: Thu, 29 Apr 2004 12:40:15 +0100 Message-ID: <3763.1083238815@csr.com> From: Peter Stephenson X-OriginalArrivalTime: 29 Apr 2004 11:44:03.0734 (UTC) FILETIME=[45548360:01C42DDF] X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: * X-Spam-Status: No, hits=1.6 required=6.0 tests=BAYES_60 autolearn=no version=2.63 X-Spam-Hits: 1.6 zzapper wrote: > On Wed, 28 Apr 2004 18:39:05 +0100, wrote: > > >zzapper wrote: > >> Hi, > >> > >> > cmd1 p1 p2 p3 > >> > cmd2 > >> .... > >> ... > >> > >> > cmdx p4 p5 > >> > cmdy umb > >> er?> > > > >cmdy !?cmd1?:* > > > That's cool, bit of a type-fest though!! Here's a zle widget called insert-args-of which does the whole thing. Type `cmd1' and execute the widget. Actually, !? searches for a string inside the command, so it's more powerful than I suggested. What you asked for works without the `?'s. Works without `banghist' in use, since turning that on locally seems to be sufficient. #start # Zle widget to look at a string and replace it with the arguments # of the last command in the history containing that string. emulate -L zsh setopt banghist # Remember position integer pos=$CURSOR # Find start of word. Just use whitespace. while [[ $CURSOR -gt 1 && $LBUFFER[-1] != [[:space:]] ]]; do (( CURSOR-- )) done # Insert history substitution characters LBUFFER+="!?" # Go back to start position, remembering extra characters. (( CURSOR = pos + 2 )) # Search for end of word. while [[ -n $RBUFFER && $RBUFFER[1] != [[:space:]] ]]; do (( CURSOR++ )) done # Insert trailing history substitution characters. LBUFFER+="?:*" # Use magic-space to expand the history substitution. zle magic-space #end -- Peter Stephenson Software Engineer CSR Ltd., Science Park, Milton Road, Cambridge, CB4 0WH, 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. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com **********************************************************************