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

issue with completion of "module" command when using lmod



Dear zsh-workers,

when using lmod for "module", Modulefiles have a ".lua" extension. With
the current completion as defined in "_module", this file extension is not
cut off and thus erroneously appears when one tries to load a module:

  module load compiler/GCC/10<TAB>
results in
  module load compiler/GCC/10.2.0.lua
instead of
  module load compiler/GCC/10.2.0

(and "module load compiler/GCC/10.2.0.lua" fails in
  Lmod has detected the following error:  The following module(s) are
  unknown: "compiler/GCC/10.2.0.lua")

The patch below fixes this issue by cutting of the lua-extension.

Best regards,
Max

--- snip ---

/usr/share/zsh/functions/Completion/Unix/_module
@@ -85,7 +85,7 @@
 {
   if [[ -n $MODULEPATH ]] && [[ ${+_available_modules} -eq 0 ]]
   then
-    _available_modules=(${$(find -L ${(e)=MODULEPATH//:/ } -type f -print 2>/dev/null | grep -v \\.version | sed -e 's,\('${${(e)=MODULEPATH//:/\/\\\|}%\\\|}'\),,g' -e 's,^/*,,g'):#*\~})
+    _available_modules=(${$(find -L ${(e)=MODULEPATH//:/ } -type f -print 2>/dev/null | grep -v \\.version | sed -e 's,\('${${(e)=MODULEPATH//:/\/\\\|}%\\\|}'\),,g' -e 's,^/*,,g' -e 's,\.lua$,,g'):#*\~})
   fi
 }




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