From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26695 invoked by alias); 24 Aug 2017 21:15:42 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 41597 Received: (qmail 7269 invoked by uid 1010); 24 Aug 2017 21:15:42 -0000 X-Qmail-Scanner-Diagnostics: from mail-qt0-f182.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.216.182):SA:0(-2.1/5.0):. Processed in 3.204006 secs); 24 Aug 2017 21:15:42 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_SORBS_SPAM,SPF_PASS, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | 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== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=mCzv8ut8A/Lhgji/DH7qwbqIX2400EB+FjKSmk7Zc9Y=; b=Vnb4hoBarDbfnKjd4YYDe4qej+DAgRBf6skVq4tHkI5w6C9qeMC0zr2RarRXnYkDHV WuPWcabkiuErY3+KuR/xp099eBEavRlV2v/V0rF+M0uspxH1KfMNLEx5hm/C4hUyYrQK NYCJ2IP+N+OewRqfW9ygcfvit9oCrq0ps2qzgtNennCnbtDDSkuXKAmiRgA0jMTJfMxf wF6aAVzDGiDVqgQEZAY0ZXu2cyRc3b69mZuGBOMOhnCE6I6+Veyhzvl/Qirtwuaw+R2A YnbngJsufQBIZvit3co0N+F4FiHgtsQZrxObid0EG+xpWEWzTiYT3JxIFAEw5DFuql+8 Tc1w== X-Gm-Message-State: AHYfb5hvhxKdSZ5CIZDaD/szehR0yeGyMt15TuIsAGYYZKY0fFPv8K2P hytQNup5dk2UgK9HfrpJbr+NonQczw1tkdw= X-Received: by 10.237.42.114 with SMTP id k47mr10993708qtf.71.1503609335409; Thu, 24 Aug 2017 14:15:35 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Bart Schaefer Date: Thu, 24 Aug 2017 14:15:34 -0700 Message-ID: Subject: Re: Skip singleton directories when tab completing To: "zsh-workers@zsh.org" Content-Type: text/plain; charset="UTF-8" On Thu, Aug 24, 2017 at 12:37 PM, Daniel Li 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.