From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27218 invoked by alias); 23 Feb 2018 14:47:17 -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: 23165 Received: (qmail 28167 invoked by uid 1010); 23 Feb 2018 14:47:17 -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 0.4498 secs); 23 Feb 2018 14:47:17 -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: Re: Dynamic named directories and completion Date: Fri, 23 Feb 2018 09:42:37 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit 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 In-Reply-To: Content-Language: en-US On 2/23/18 3:01 AM, Vincent Bernat wrote: > ❦ 22 février 2018 17:54 -0500, Scott Frazer  : > >> 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? > > I don't see anything wrong in your code and for me, it works as you > expect (zsh 5.4.2). Does "echo ~[ccc]" returns the right value? > Yes, "echo ~[ccc]" works correctly. I'm using zsh 5.3 so maybe there is some difference there. Perhaps there is some difference in options/modules/etc. If I cut my .zshrc down to a minimum: autoload -Uz compinit compinit zstyle ':completion:*' verbose yes zstyle ':completion:*' menu select=2 zstyle ':completion:*:messages' format '%d' zstyle ':completion:*' group-name '' zstyle ':completion:*' squeeze-slashes true zstyle ':completion:*:descriptions' format "%UCompleting %d:%u" zstyle ':completion:*:warnings' format "No matches for: %d" (with the above zsh_directory_name() too of course), plain ~[whatever] works but ~[whatever]/ will not complete paths. Do you have anything non-standard in your completion? Scott