zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: Completion lists
Date: Tue, 13 Sep 2011 07:43:20 -0700	[thread overview]
Message-ID: <110913074320.ZM14249@torch.brasslantern.com> (raw)
In-Reply-To: <loom.20110913T144601-8@post.gmane.org>

On Sep 13, 12:54pm, Yuri DElia wrote:
}
} I would like to highlight (in bold) the trailing/ambiguous part (typed in caps
} here):
} 
} $ cd prog<TAB>
} progRAM
} progMAN
} progWHATEVER

You should be able to do this with something like:

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.

It won't work all the time because completion is a really complex beast.
You probably need to do the above a few times replacing "default" with
different tags.

For example, above I've use the tail (:t) of the current word so that
it'll do something useful when completing files in subdirectories, but
that isn't really necessary when completing variable names or options.
You might want to use one pattern for file completion and another for
other contexts.

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")'

If someone builds up a useful set of these based on this example, please
post back to the list.


  reply	other threads:[~2011-09-13 14:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-13 12:54 Yuri DElia
2011-09-13 14:43 ` Bart Schaefer [this message]
2011-09-13 15:16   ` Yuri DElia
2011-09-13 16:07     ` Yuri DElia
2011-09-13 17:40       ` Bart Schaefer
2011-09-13 18:48         ` Yuri DElia
2011-09-16 21:04         ` Peter Stephenson
2011-09-16 21:07           ` Peter Stephenson
2011-09-13 16:29     ` Bart Schaefer
2011-09-13 17:11       ` Yuri DElia
2011-09-18 13:41   ` Yuri DElia
2011-09-18 13:48     ` Mikael Magnusson
     [not found]       ` <ed790212f803298ea33fd6091b9d5062@thregr.org>
2011-09-18 14:08         ` Mikael Magnusson
2011-09-18 14:35           ` Yuri D'Elia
2011-09-16 21:58 ` Tomasz Pala

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=110913074320.ZM14249@torch.brasslantern.com \
    --to=schaefer@brasslantern.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).