Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Minor tweak for _module completion

On Sat, 30 Aug 2008 03:58:11 -0700 (PDT)
Daniel Qarras <dqarras@xxxxxxxxx> wrote:
> the attached patch hides backup files (ending with ~, often created
> unknowingly with emacs by many users) while completing for "module".
> (I presume it was ok to use "grep -E" instead of two grep commands,
> ie, "grep -E" should be supported where zsh can be used? If not, please
> feel free to modify if needed.)

The following simply strips modules ending in "~" within the shell,
instead.  I haven't tried it out since I don't have a suitable set-up.

It ought to be possible to make _module use $fignore (or the equivalent
as a style) but I haven't investigated that.  It would be neater to do
that, but it would take more fiddling around and this is a common enough
case it's probably worth doing anyway.

Index: Completion/Unix/Command/_module
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_module,v
retrieving revision 1.6
diff -u -r1.6 _module
--- Completion/Unix/Command/_module	2 Oct 2007 09:08:27 -0000	1.6
+++ Completion/Unix/Command/_module	30 Aug 2008 11:52:26 -0000
@@ -85,7 +85,7 @@
   if [[ -n $MODULEPATH ]] && [[ ${+_available_modules} -eq 0 ]]
-    _available_modules=($(find ${(e)=MODULEPATH//:/ } -xtype f -print 2>/dev/null | grep -v \\.version | sed -e 's,\('${${(e)=MODULEPATH//:/\/\\\|}%\\\|}'\),,g' -e 's,^/*,,g'))
+    _available_modules=(${$(find ${(e)=MODULEPATH//:/ } -xtype f -print 2>/dev/null | grep -v \\.version | sed -e 's,\('${${(e)=MODULEPATH//:/\/\\\|}%\\\|}'\),,g' -e 's,^/*,,g'):#*\~})

Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/

Messages sorted by: Reverse Date, Date, Thread, Author