From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14139 invoked by alias); 19 Aug 2012 00:18:43 -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: X-Seq: 17204 Received: (qmail 12640 invoked from network); 19 Aug 2012 00:18:41 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <120818171826.ZM18675@torch.brasslantern.com> Date: Sat, 18 Aug 2012 17:18:26 -0700 In-reply-to: Comments: In reply to Karoly Negyesi "Recursive Completition" (Aug 18, 11:09pm) References: X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: Recursive Completition MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Aug 18, 11:09pm, Karoly Negyesi wrote: } } ls **/Kernel.php[Tab] } } autocompletes to } } core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php } } that's really great! Glad you like it, but you should understand the difference between _completion_ and _expansion_ before going any further. What you've done right there is _expansion_ -- replace a glob pattern with the thing(s) it matches (expands to). This happens to be handled as part of the completion system if you've run "compinit" but it's really not quite the same thing, because it isn't applying any contextual clues to the pattern, it's just expanding it. Note that the default behavior is to try expansion first and complete only if that fails. } Even better would be if I could have } } ls **/Kern[tab] } } do that (and not just for ls, but everything else). Here the glob pattern doesn't match (because there's no file named "Kern" anywhere downstream), so it doesn't expand to anything. If you tried ls **/Kern*[tab] you'd get something (possibly many somethings). Fortunately there's a way to move this out of the realm of expansion and into that of completion; to whit, simply assert that you want completion to act as if it were using glob patterns: setopt globcomplete Now when you try ls **/Kern[tab] the completion system behaves as if you'd inserted a * just before [tab], and offers you the list of matching items as choices. It's not quite as intutive when encountering a possible branch part way down the **/ expansion -- you may be offered a set of directories as the alternatives with no obvious way to choose one of them and then go on with the same completion. This gets easier if you force menu-selection to occur. } Oh, and maybe display the menu while I am writing a wishlist :) That's all independently controlled by things like setopt automenu zstyle ':completion:*' menu 'yes=long' 'select=9' and so on. There's a bunch of stuff about this toward the end of section 6.5.2 http://zsh.sourceforge.net/Guide/zshguide06.html#l158 of the user guide. } Perfect would be just } } ls Kern[tab] } } to do that. I am aware of the performance implications -- could this } be restricted to the user's home dir only so it doesnt try to read the } whole OS when in the root. This one would require that you create a new widget or a new completion function to insert the implicit leading **/ in the right contexts. It's certainly do-able, but I'm going to leave it as an exercise for someone else, this time.