From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8147 invoked from network); 15 Nov 2006 11:09:39 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) 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.7 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 15 Nov 2006 11:09:39 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 26934 invoked from network); 15 Nov 2006 11:09:32 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 15 Nov 2006 11:09:32 -0000 Received: (qmail 11170 invoked by alias); 15 Nov 2006 11:09:24 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10988 Received: (qmail 11161 invoked from network); 15 Nov 2006 11:09:23 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 15 Nov 2006 11:09:23 -0000 Received: (qmail 25863 invoked from network); 15 Nov 2006 11:09:23 -0000 Received: from cluster-c.mailcontrol.com (168.143.177.190) by a.mx.sunsite.dk with SMTP; 15 Nov 2006 11:09:20 -0000 Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly19c.srv.mailcontrol.com (MailControl) with ESMTP id kAFB6RW7018649 for ; Wed, 15 Nov 2006 11:09:09 GMT Received: from news01.csr.com ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.1830); Wed, 15 Nov 2006 11:08:40 +0000 Date: Wed, 15 Nov 2006 11:08:40 +0000 From: Peter Stephenson To: zsh-users@sunsite.dk Subject: Re: Adding array content to cd completion Message-Id: <20061115110840.ee8e44ad.pws@csr.com> In-Reply-To: <20061115050938.GC7601@princo> References: <20061115050938.GC7601@princo> Organization: Cambridge Silicon Radio X-Mailer: Sylpheed version 2.2.9 (GTK+ 2.8.20; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 15 Nov 2006 11:08:40.0619 (UTC) FILETIME=[68065FB0:01C708A6] X-Scanned-By: MailControl A-07-06-70 (www.mailcontrol.com) on 10.67.0.129 Jean-Rene David wrote: > I have an array of directories I frequently visit. > I would like the completion of "cd" to include > those directories, as a separate group. It depends how much work you want to do. If you don't mind them appearing as named directories you can do: mydirs=(mydir1 mydir1) zstyle -e ':completion::complete:cd:*:named-directories' fake '$mydirs' If you really want a separate group it's harder. The whole completion system is written so that only a fixed set of tags are available for each completion. It's possible to use the tag-order to split a group into two, as described in the manual. You can use this with, say, the named-directories tag to have a normal completion and your own context. In your own context you have to add your own matches using the fake style and then (the hairiest part of the exercise) remove the normal matches with ignored-patterns. Luckily in this case the matches to be ignored are parameter names available from the associatiave array $nameddirs: zstyle ':completion::complete:cd:*' tag-order \ 'named-directories:-mine:extra\ directories named-directories:-normal:named\ directories *' mydirs=(mydir1 mydir2) zstyle -e ':completion::complete:cd:*:named-directories-mine' fake \ 'reply=($mydirs)' zstyle -e ':completion::complete:cd:*:named-directories-mine' \ ignored-patterns 'reply=("(${(qkj.|.)nameddirs})")' This seems to work. It's not clear it's easier than redefining _cd. Arguably there should be an easier way of saying only use the fake matches. I think that's quite difficult since all the normal matches have been added and are in the shell's internal structures by the time that style is processed. -- 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