From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17701 invoked from network); 11 Mar 2004 12:28:37 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 11 Mar 2004 12:28:37 -0000 Received: (qmail 19659 invoked by alias); 11 Mar 2004 12:28:19 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7135 Received: (qmail 19648 invoked from network); 11 Mar 2004 12:28:19 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 11 Mar 2004 12:28:19 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [62.189.58.19] by sunsite.dk (MessageWall 1.0.8) with SMTP; 11 Mar 2004 12:28:18 -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 i2BCSHv04619 for ; Thu, 11 Mar 2004 12:28:17 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, 11 Mar 2004 12:27:57 +0000 Received: from csr.com ([192.168.144.127]) by EXCHANGE02.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Thu, 11 Mar 2004 12:30:16 +0000 To: zsh-users@sunsite.dk Subject: Re: cd completion and CDABLE_VARS In-reply-to: "Vincent Lefevre"'s message of "Thu, 11 Mar 2004 12:45:49 +0100." <20040311114549.GJ16556@ay.vinc17.org> Date: Thu, 11 Mar 2004 12:28:17 +0000 Message-ID: <14646.1079008097@csr.com> From: Peter Stephenson X-OriginalArrivalTime: 11 Mar 2004 12:30:16.0770 (UTC) FILETIME=[9BF27A20:01C40764] Vincent Lefevre wrote: > When I use completion with the cd command, zsh tries to complete > to both directories and named directories, probably because I have > CDABLE_VARS set. I would like cd to complete to directories by > default, and if it is not possible (and only in this case), then > the completion to named directories is performed. How can I do > that? This is an interesting question and I'm glad you asked (assuming Oliver hasn't beaten me to it)... There's a general procedure for things like this, whenever you have recognisably different completions at a particular point. Obviously, that means `recognisable by the completion system', so it requires someone to have thought about this in the implemenation of the function. However, that happens to be the case here. Go to the point where you want completion to be performed and type ^xh. You should get something like: tags in context :completion::complete:cd:: local-directories path-directories named-directories (_alternative _cd) users named-directories directory-stack (_tilde _alternative _cd) users (_users _tilde _alternative _cd) (I actually typed `cd z^xh' but it shouldn't matter much.) Those names on the left of the list are what you want. You now need to tell the completion system what order you want it to show the tags: zstyle ':completion:*:complete:cd:*' tag-order \ 'local-directories path-directories directory-stack' '*' You may decide a different order, but the point is that `named-directories' are not in the first set. Note that I have tied this to the cd command; you could used `(cd|pushd)', for example. Now you should find you only get shown real directories and directory stack entries, unless there aren't any. One extra tip is that there is a widget _next_tags which you can use to switch to the next set of tags even if the first set isn't empty. It switches round in a circle. I use: bindkey "^X^N" _next_tags -- 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 **********************************************************************