* PATH_DIRS and command completion
@ 2012-01-06 17:11 Christian Neukirchen
2012-01-07 20:35 ` Peter Stephenson
0 siblings, 1 reply; 2+ messages in thread
From: Christian Neukirchen @ 2012-01-06 17:11 UTC (permalink / raw)
To: zsh-users
Hi,
just yesterday I found the PATH_DIRS option and really like the
behavior:
% ls -l /usr/bin/core_perl/cpan
-rwxr-xr-x 1 root root 5094 Dec 29 21:46 /usr/bin/core_perl/cpan*
% core_perl/cpan
zsh: no such file or directory: core_perl/cpan
% setopt PATH_DIRS
% core_perl/cpan
cpan shell -- CPAN exploration and modules installation (v1.960001)
...
Unfortunately, tab command completion doesn't complete the folders in
$PATH. Has anyone hacked that in already?
I.e. I want:
% cor<TAB>
core corelist corepkg corrupt_mpeg2 core_perl/
% core_perl/<TAB>
c2ph* dprofpp* libnetcfg* pod2html* prove* shasum*
config_data* enc2xs* perlbug* pod2latex* psed@ splain*
...
Cheers,
--
Christian Neukirchen <chneukirchen@gmail.com> http://chneukirchen.org
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: PATH_DIRS and command completion
2012-01-06 17:11 PATH_DIRS and command completion Christian Neukirchen
@ 2012-01-07 20:35 ` Peter Stephenson
0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2012-01-07 20:35 UTC (permalink / raw)
To: zsh-users
On Fri, 06 Jan 2012 18:11:22 +0100
Christian Neukirchen <chneukirchen@gmail.com> 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 <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-01-07 20:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-06 17:11 PATH_DIRS and command completion Christian Neukirchen
2012-01-07 20:35 ` Peter Stephenson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).