From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2215 invoked by alias); 7 Jan 2012 20:43:07 -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: 16711 Received: (qmail 13132 invoked from network); 7 Jan 2012 20:43:05 -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=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 Received-SPF: neutral (ns1.primenet.com.au: 209.85.212.171 is neither permitted nor denied by SPF record at ntlworld.com) X-ProxyUser-IP: 86.6.29.42 Date: Sat, 7 Jan 2012 20:35:43 +0000 From: Peter Stephenson To: zsh-users@zsh.org Subject: Re: PATH_DIRS and command completion Message-ID: <20120107203543.204549fc@pws-pc.ntlworld.com> In-Reply-To: <87vcooiwn9.fsf@gmail.com> References: <87vcooiwn9.fsf@gmail.com> X-Mailer: Claws Mail 3.7.10 (GTK+ 2.24.7; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 06 Jan 2012 18:11:22 +0100 Christian Neukirchen wrote: > just yesterday I found the PATH_DIRS option and really like the > behavior: > > Unfortunately, tab command completion doesn't complete the folders in > $PATH. Has anyone hacked that in already? I think this does it, and also completes executables in the folders so found, but let me know... Index: Completion/Unix/Type/_path_commands =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_path_commands,v retrieving revision 1.6 diff -p -u -r1.6 _path_commands --- Completion/Unix/Type/_path_commands 2 Nov 2008 14:12:30 -0000 1.6 +++ Completion/Unix/Type/_path_commands 7 Jan 2012 20:34:18 -0000 @@ -82,6 +82,18 @@ if [[ -n $need_desc ]]; then else _wanted commands expl 'external command' compadd "$@" -k commands && ret=0 fi +if [[ -o path_dirs ]]; then + local -a path_dirs + path_dirs=(${^path}/*(/N:t)) + (( ${#path_dirs} )) && + _wanted path-dirs expl 'directory in path' compadd "$@" -a path_dirs && ret=0 + + if [[ $PREFIX$SUFFIX = */* ]]; then + # Find command from path, not hashed + _wanted commands expl 'external command' _path_files -W path -g '*(*)' && + ret=0 + fi +fi return $ret } -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/