简体   繁体   中英

tcsh autocompletion for modulefiles

I found this piece of code, which does auto-completion for module files in tcsh at https://opensource.apple.com/source/tcsh/tcsh-66/tcsh/complete.tcsh .

Could somebody help me understand how the 'alias Compl_module' works?

#from Dan Nicolaescu <dann@ics.uci.edu>
if ( $?MODULESHOME ) then
  alias Compl_module 'find ${MODULEPATH:as/:/ /} -name .version -o -name .modulea\* -prune -o -print  | sed `echo "-e s@${MODULEPATH:as%:%/\*@@g -e s@%}/\*@@g"`'
  complete module 'p%1%(add load unload switch display avail use unuse update purge list clear help initadd initrm initswitch initlist initclear)%' \
  'n%{unl*,sw*,inits*}%`echo "$LOADEDMODULES:as/:/ /"`%' \
  'n%{lo*,di*,he*,inita*,initr*}%`eval Compl_module`%' \
  'N%{sw*,initsw*}%`eval Compl_module`%' 'C%-%(-append)%' 'n%{use,unu*,av*}%d%' 'n%-append%d%' \
  'C%[^-]*%`eval Compl_module`%'
endif

Thanks a lot.

Not sure this Compl_module alias is performing well as it tries to determine all existing modulefiles in modulepaths by just looking at existing files. Modulefiles can also be aliases, symbolic versions and virtual (in newer Modules versions >=4.1), so the Compl_module alias will miss that.

You will find a full completion script for the module command in the source repository of the Modules project .

This completion script calls module avail to correctly get all existing modulefiles in enabled modulepaths.

TCSH completion script is automatically enabled starting Modules version 4.0.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM