From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12905 invoked from network); 6 Oct 2006 15:08:23 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.6 (2006-10-03) 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.6 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 6 Oct 2006 15:08:23 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 16776 invoked from network); 6 Oct 2006 15:08:17 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 6 Oct 2006 15:08:17 -0000 Received: (qmail 4754 invoked by alias); 6 Oct 2006 15:08:09 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10793 Received: (qmail 4741 invoked from network); 6 Oct 2006 15:08:08 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 6 Oct 2006 15:08:08 -0000 Received: (qmail 15613 invoked from network); 6 Oct 2006 15:08:07 -0000 Received: from cluster-c.mailcontrol.com (168.143.177.190) by a.mx.sunsite.dk with SMTP; 6 Oct 2006 15:08:02 -0000 Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly14c.srv.mailcontrol.com (MailControl) with ESMTP id k96F7ksE021614 for ; Fri, 6 Oct 2006 16:07:56 +0100 Received: from news01.csr.com ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.1830); Fri, 6 Oct 2006 16:07:51 +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 k96F7oNX001002 for ; Fri, 6 Oct 2006 16:07:50 +0100 Received: from csr.com (pws@localhost) by news01.csr.com (8.13.7/8.13.7/Submit) with ESMTP id k96F7nU8000999 for ; Fri, 6 Oct 2006 16:07:50 +0100 Message-Id: <200610061507.k96F7nU8000999@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: zsh-users@sunsite.dk (Zsh users list) Subject: Move command line options to start of line Date: Fri, 06 Oct 2006 16:07:48 +0100 From: Peter Stephenson X-OriginalArrivalTime: 06 Oct 2006 15:07:51.0369 (UTC) FILETIME=[31370B90:01C6E959] Content-Type: text/plain MIME-Version: 1.0 X-Scanned-By: MailControl A-07-04-02 (www.mailcontrol.com) on 10.67.0.124 Not sure if anybody actually needs such a thing, but the Austin group (essentially POSIX) has been worrying about it, so I thought I'd while away Friday afternoon by writing a zle widget (looks like Chris Johnson had a similar idea...) Unfortunately zsh is so powerful it was trivial. See the description at the top. #top # This moves an option, possibly with arguments, from before the # cursor to immediately after the command word. # Examples (cursor assumed to be at the end of the line): # ls file1 file2 -l # -> ls -l files 1files # # p4 opened -u pws # -> p4 -u pws opened # # In the unlikely event that the argument of an option begins with -, # repeated application will have the correct effect. local -a line integer i line=(${(z)LBUFFER}) i=${line[(I)-*]} (( i < 3 )) && return 1 LBUFFER="$line[1] $line[i,-1] $line[2,i-1]" #bottom -- 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