zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-users@sunsite.dk
Subject: Re: cd completion and CDABLE_VARS
Date: Thu, 11 Mar 2004 12:28:17 +0000	[thread overview]
Message-ID: <14646.1079008097@csr.com> (raw)
In-Reply-To: "Vincent Lefevre"'s message of "Thu, 11 Mar 2004 12:45:49 +0100." <20040311114549.GJ16556@ay.vinc17.org>

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 <pws@csr.com>                  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
**********************************************************************


  reply	other threads:[~2004-03-11 12:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-11 11:45 Vincent Lefevre
2004-03-11 12:28 ` Peter Stephenson [this message]
2004-03-11 13:35   ` Stefan Reichör
2004-03-11 14:11     ` Peter Stephenson
2004-03-11 14:46       ` Stefan Reichör
2004-03-11 15:05         ` Peter Stephenson
2004-03-11 15:28           ` Stefan Reichör
2004-03-11 15:45             ` Peter Stephenson
2004-03-11 15:55               ` Stefan Reichör
2004-03-11 16:26   ` Vincent Lefevre
2004-03-11 16:41     ` Vincent Lefevre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=14646.1079008097@csr.com \
    --to=pws@csr.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).