From: Peter Stephenson <pws@csr.com>
To: zsh-users@sunsite.dk
Subject: Re: Adding array content to cd completion
Date: Wed, 15 Nov 2006 11:08:40 +0000 [thread overview]
Message-ID: <20061115110840.ee8e44ad.pws@csr.com> (raw)
In-Reply-To: <20061115050938.GC7601@princo>
Jean-Rene David <jrdavid@magma.ca> 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 <pws@csr.com> 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
next prev parent reply other threads:[~2006-11-15 11:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-15 5:09 Jean-Rene David
2006-11-15 5:27 ` arno.
2006-11-15 6:09 ` Jean-Rene David
2006-11-15 11:08 ` Peter Stephenson [this message]
2006-11-15 14:54 ` Peter Stephenson
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=20061115110840.ee8e44ad.pws@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).