From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13585 invoked by alias); 22 Feb 2018 22:54:40 -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: List-Unsubscribe: X-Seq: 23159 Received: (qmail 22878 invoked by uid 1010); 22 Feb 2018 22:54:40 -0000 X-Qmail-Scanner-Diagnostics: from 195.159.176.226 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(195.159.176.226):SA:0(2.6/5.0):. Processed in 1.90397 secs); 22 Feb 2018 22:54:40 -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.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FORGED_MUA_MOZILLA,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,NML_ADSP_CUSTOM_MED,RDNS_NONE autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: gcszu-zsh-users@m.gmane.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | X-Injected-Via-Gmane: http://gmane.org/ To: zsh-users@zsh.org From: Scott Frazer Subject: Dynamic named directories and completion Date: Thu, 22 Feb 2018 17:54:24 -0500 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@blaine.gmane.org User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 X-Mozilla-News-Host: news://news.gmane.org:119 Content-Language: en-US I'm trying to use dynamic named directories and have subsequent completion work. Here is my (perhaps naive) attempt: zsh_directory_name () { emulate -L zsh setopt extendedglob local -a seg; seg=(${(s:/:)PWD%/*}) if [[ $1 = n ]]; then typeset -ga reply reply=( /${(j:/:)seg[1,(I)$2]} ) elif [[ $1 = c ]]; then local expl _wanted values expl 'parent dirs' compadd -S\] -a seg else return 1 fi return 0 } Suppose I am in directory /aaa/bbb/ccc/ddd/eee and want to go up to directory ccc and then down into another directory. If I do: cd ~[c it correctly completes to: cd ~[ccc] If I hit enter at this point I go to /aaa/bbb/ccc. So far so good. If I try to start completion, like so: cd ~[ccc]/ zsh doesn't give me options for directories under ccc, it thinks '/' is the command I'm trying to complete. Is there a way to make this work? Thanks, Scott