From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27572 invoked by alias); 13 Sep 2011 15:16:39 -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: 16340 Received: (qmail 21824 invoked from network); 13 Sep 2011 15:16:34 -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=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at m.gmane.org designates 80.91.229.12 as permitted sender) X-Injected-Via-Gmane: http://gmane.org/ To: zsh-users@zsh.org From: Yuri DElia Subject: Re: Completion lists Date: Tue, 13 Sep 2011 15:16:12 +0000 (UTC) Message-ID: References: <110913074320.ZM14249@torch.brasslantern.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: sea.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 93.89.57.166 (Mozilla/5.0 (X11; Linux x86_64; rv:6.0.2) Gecko/20100101 Firefox/6.0.2 Iceweasel/6.0.2) Bart Schaefer brasslantern.com> writes: > zstyle -e ':completion:*:default' list-colors \ > 'reply=("=(#b)${words[CURRENT]:t}(*)=0=7")' > > The -e option evaluates the style so you can use $words[CURRENT] to put > the string from the line into the style. The highlight is controlled > by the =0=3 part, where =0 means no highlight on the parts that are > not matched by a pattern in parens and the =7 means use reverse video > on the part matched by the first sub-pattern in parens (here "(*)"). > See the doc for the complist module ZLS_COLORS variable. Your code seem to fail badly with directories. For instance, completing anything with "./" will incorrectly skip the first two characters of the files themselves. > If you've got matcher-list styles that do fancy completion in the middle > of words, $words[CURRENT] is going to be inadequate to the task (and it > is likely that nothing you can expand at the time the list-colors style > is evaluated would be sufficient). You might specify case-insensitive > globbing on to help with mixed-case matcher-lists: > > zstyle -e ':completion:*:default' list-colors \ > 'reply=("=(#bi)${words[CURRENT]:t}(*)=0=7")' While I was waiting I kept trying and came up with this: c='${PREFIX:+=(#b)($PREFIX:t)(?)*===$color[bold]}':'=(#b)(?)*==$color[bold]' zstyle -e ':completion:*' list-colors "reply=(\"$c\")" The first part of the reply matches the first character after the prefix. The second matches the first character in a list (when completing directories). Seems to work fine for both files and parameters. Doesn't work for anything beyond prefix matching: $ ls ///list (ambiguous) etc/ lib/ usr/ will simply put the cursor after the first / and highlight the third characters of the list (and I don't understand why). I'm wondering what variables could in the reply. I found $PREFIX in other examples, and now also $words[CURRENT]. Is there a list for these? Maybe I could make it work if I had SUFFIX/somethingelse. > If someone builds up a useful set of these based on this example, please > post back to the list. I would also be glad.