From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6310 invoked by alias); 13 Oct 2011 15:32:00 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16479 Received: (qmail 7228 invoked from network); 13 Oct 2011 15:31:58 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Thu, 13 Oct 2011 15:45:28 +0100 From: Peter Stephenson To: Subject: Re: Command completion slowness? (And PATH order possible?) Message-ID: <20111013154528.176a49fc@pwslap01u.europe.root.pri> In-Reply-To: References: Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.103.10.83] X-Scanned-By: MailControl 7.6.3 (www.mailcontrol.com) on 10.71.0.123 On Thu, 13 Oct 2011 06:56:55 +0000 Daniel 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-- 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 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