Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Skip singleton directories when tab completing
- X-seq: zsh-workers 41597
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Subject: Re: Skip singleton directories when tab completing
- Date: Thu, 24 Aug 2017 14:15:34 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=mCzv8ut8A/Lhgji/DH7qwbqIX2400EB+FjKSmk7Zc9Y=; b=MJSg5M9I2gIeVZyuZzeZCAsa8b6eF5DSLyDp1MUxdQc0DZixUG/jCqhl0e5GLqn27W Wmsrn6ZnL5cOueylYsHY876ED5KLDk7ppO+pqKb84o7bwqalK9MKicPdIGusdaMr5upw yX0IOvj3vVulBkJ27f1fWsqQbRxAmvhd7BuDqIbt2LGBHvul+K8uM0ds/NfZyd+GFGE1 kGp0yGA1WMxvJYwo3A99etaqHzVnCzvPEwVduGLIdVelzt9eJc9DnfvKhGIpzztSyGDV dwtPizJeSNaLhuZ3R0j+cnc+fsg2bxAQBKOdtrIi285b8dpcSrjau7yDiUQ+hljoA2t9 FuIw==
- In-reply-to: <CAN_nDg67HOSAWif-CKeidkj2B3S3KGdzhCBVxRs8+vUZF8z3+Q@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAN_nDg67HOSAWif-CKeidkj2B3S3KGdzhCBVxRs8+vUZF8z3+Q@mail.gmail.com>
On Thu, Aug 24, 2017 at 12:37 PM, Daniel Li <dan@xxxxxxxxxx> wrote:
>
> Is there a Zsh feature that autocompletes all the singleton
> directories so that I can directly go to the leaf dir?
Assuming you've set up compinit ...
I've been using the following function in conjunction with the
_user_expand completer:
--- 8< --- _glob_expand --- 8< ---
#autoload
# Plugin for the _user_expand completer.
# Recommended usage:
# zstyle ':completion:*:user-expand:*:' user-expand _glob_expand
# zstyle ':completion:*:user-expand:*:' tag-order 'expansions all-expansions'
# Attempt expansion with an additional "*" inserted at the cursor.
reply=( $~1* )
--- >8 --- _glob_expand --- >8 ---
The zstyles as shown in the comments above plus:
zstyle ':completion:*' completer _oldlist _expand _complete _match
_user_expand _ignored _approximate _prefix
(adjust for your preference).
What this allows you to do is to use the ** recursive glob operator in
your completion, e.g.
% cd src/**/meta
will tab-complete to
% cd src/main/scala/com/tubitv/metadata
Normally this would fail because for **/ to expand the final component
has to match more than a prefix, but by appending * it tries it as a
prefix match and expands the full recursion.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author