From: Peter Stephenson <Peter.Stephenson@csr.com>
To: <zsh-users@zsh.org>
Subject: Re: Command completion slowness? (And PATH order possible?)
Date: Thu, 13 Oct 2011 15:45:28 +0100 [thread overview]
Message-ID: <20111013154528.176a49fc@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <slrnj9d2tm.q37.quite@kelebek.lublin.se>
On Thu, 13 Oct 2011 06:56:55 +0000
Daniel <quite@hack.org> wrote:
> Moreover, can I have command completion in PATH order? Specifically I have
> $USER/bin first in my PATH, and would really like first hit partial matches
> from that directory, and later from others.
Hmmm...
Here's a style path-tags that splits up commands into tags based on
the position in the path. The tags are command-<index>-<name> to allow
you to match on tags in clever ways. It definitely won't help your
speed problems.
You can then set an appropriate tag-order style, although if you use
group names,
zstyle ':completion:*:complete:*' path-tags true
zstyle ':completion:*' group-name ''
zstyle ':completion:*' format 'Completing %d'
in combination with menu selection you'll get the effect of ordering.
I'm not sure if there's a clever way with tag-order to get command-<->-*
to sort appropriately, but if there isn't there probably ought to be.
(I haven't zero-filled the number so if you had more than 10 entries in
$path you'd need the effect of numericglobsort to get the ordering.)
Doesn't work with the extra-verbose style, though I can't say I have
*that* much sympathy.
Index: Completion/Unix/Type/_path_commands
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_path_commands,v
retrieving revision 1.6
diff -p -u -r1.6 _path_commands
--- Completion/Unix/Type/_path_commands 2 Nov 2008 14:12:30 -0000 1.6
+++ Completion/Unix/Type/_path_commands 13 Oct 2011 14:34:00 -0000
@@ -80,7 +80,19 @@ if [[ -n $need_desc ]]; then
compadd "$@" -ld descs -a dcmds && ret=0
_wanted commands expl 'external command' compadd "$@" -a cmds && ret=0
else
- _wanted commands expl 'external command' compadd "$@" -k commands && ret=0
+ if zstyle -t ":completion:${curcontext}:" path-tags; then
+ integer i
+ local -a path_commands
+ for (( i = 1; i <= ${#path}; i++ )); do
+ path_commands=(${${commands:#^$path[i]/*}:t})
+ if (( ${#path_commands} )); then
+ _wanted commands-$i-${path[i]} expl "external command [${path[i]}]" \
+ compadd "$@" -k path_commands
+ fi
+ done
+ else
+ _wanted commands expl 'external command' compadd "$@" -k commands && ret=0
+ fi
fi
return $ret
--
Peter Stephenson <pws@csr.com> Software Engineer
Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
prev parent reply other threads:[~2011-10-13 15:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-13 6:56 Daniel
2011-10-13 14:45 ` Peter Stephenson [this message]
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=20111013154528.176a49fc@pwslap01u.europe.root.pri \
--to=peter.stephenson@csr.com \
--cc=zsh-users@zsh.org \
/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).