/usr/share/modules/init/bash_completion is in environment-modules 4.1.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | #
# Bash commandline completion (bash 3.0 and above)
#
_module_avail() {
module avail -t 2>&1 | sed '
/^-\+/d; /^\s*$/d;
/->.*$/d;
/:$/d;
/:ERROR:/d;
s#^\(.*\)/\(.\+\)(.*default.*)#\1\n\1\/\2#;
s#(.*)$##g;
s#\s*$##g;
s#/*$##g;'
}
_module_savelist() {
module savelist -t 2>&1 | sed '
/Named collection list$/d;
/:$/d;
/:ERROR:/d;'
}
_module_not_yet_loaded() {
_module_avail | sort | sed -r "\%^(${LOADEDMODULES//:/|})$%d"
}
_module_long_arg_list() {
local cur="$1" i
if [[ ${COMP_WORDS[COMP_CWORD-2]} == sw* ]]
then
COMPREPLY=( $(compgen -W "$(_module_not_yet_loaded)" -- "$cur") )
return
fi
for ((i = COMP_CWORD - 1; i > 0; i--))
do case ${COMP_WORDS[$i]} in
add|load)
COMPREPLY=( $(compgen -W "$(_module_not_yet_loaded)" -- "$cur") )
break;;
rm|remove|unload|switch|swap)
COMPREPLY=( $(IFS=: compgen -W "${LOADEDMODULES}" -- "$cur") )
break;;
esac
done
}
# define completion relative to active version
if [ "$MODULES_USE_COMPAT_VERSION" = '1' ]; then
_module() {
local cur="$2" prev="$3" cmds opts
COMPREPLY=()
cmds="add apropos avail clear display help\
initadd initclear initlist initprepend initrm initswitch\
keyword list load purge refresh rm show swap switch\
unload unuse update use whatis"
opts="-c -f -h -i -l -s -t -u -v -H -V\
--create --force --help --human --icase\
--long --silent --terse --userlvl --verbose --version"
case "$prev" in
add|load) COMPREPLY=( $(compgen -W "$(_module_not_yet_loaded)" -- "$cur") );;
rm|remove|unload|switch|swap)
COMPREPLY=( $(IFS=: compgen -W "${LOADEDMODULES}" -- "$cur") );;
unuse) COMPREPLY=( $(IFS=: compgen -W "${MODULEPATH}" -- "$cur") );;
use|*-a*) ;; # let readline handle the completion
-u|--userlvl) COMPREPLY=( $(compgen -W "novice expert advanced" -- "$cur") );;
av*|disp*|help|show|whatis)
COMPREPLY=( $(compgen -W "$(_module_avail)" -- "$cur") );;
*) if test $COMP_CWORD -gt 2
then
_module_long_arg_list "$cur"
else
case "$cur" in
# The mappings below are optional abbreviations for convenience
ls) COMPREPLY="list";; # map ls -> list
r*) COMPREPLY="rm";; # also covers 'remove'
sw*) COMPREPLY="switch";;
-*) COMPREPLY=( $(compgen -W "$opts" -- "$cur") );;
*) COMPREPLY=( $(compgen -W "$cmds" -- "$cur") );;
esac
fi;;
esac
}
else
_module() {
local cur="$2" prev="$3" cmds opts
COMPREPLY=()
cmds="add apropos aliases avail append-path display help initadd\
initclear initlist initprepend initrm is-loaded is-saved is-used\
is-avail info-loaded keyword list load path paths purge prepend-path\
refresh reload restore rm remove-path save savelist saveshow saverm\
search show source swap switch test unload unuse use whatis"
opts="-D -h -V --debug --help --version"
list_opts="-l -t --long --terse"
path_opts="-d --delim --duplicates"
rm_path_opts="-d --delim --index"
avail_opts="-d -L -l -t --default --latest --long --terse"
case "$prev" in
add|load) COMPREPLY=( $(compgen -W "$(_module_not_yet_loaded)" -- "$cur") );;
avail) COMPREPLY=( $(compgen -W "$avail_opts $(_module_avail)" -- "$cur") );;
list|savelist) COMPREPLY=( $(compgen -W "$list_opts" -- "$cur") );;
restore|save|saveshow|saverm|is-saved)
COMPREPLY=( $(compgen -W "$(_module_savelist)" -- "$cur") );;
rm|remove|unload|switch|swap)
COMPREPLY=( $(IFS=: compgen -W "${LOADEDMODULES}" -- "$cur") );;
unuse|is-used) COMPREPLY=( $(IFS=: compgen -W "${MODULEPATH}" -- "$cur") );;
use|-a|--append) ;; # let readline handle the completion
display|help|show|test|whatis|is-loaded|is-avail|info-loaded)
COMPREPLY=( $(compgen -W "$(_module_avail)" -- "$cur") );;
-h|--help|-V|--version|aliases|apropos|keyword|purge|refresh|reload|search|source)
;;
append-path|prepend-path)
COMPREPLY=( $(compgen -W "$path_opts" -- "$cur") );;
remove-path)
COMPREPLY=( $(compgen -W "$rm_path_opts" -- "$cur") );;
initadd|initclear|initlist|initprepend|initrm)
;;
*) if test $COMP_CWORD -gt 2
then
_module_long_arg_list "$cur"
else
case "$cur" in
# The mappings below are optional abbreviations for convenience
ls) COMPREPLY="list";; # map ls -> list
sw*) COMPREPLY="switch";;
-*) COMPREPLY=( $(compgen -W "$opts" -- "$cur") );;
*) COMPREPLY=( $(compgen -W "$opts $cmds" -- "$cur") );;
esac
fi;;
esac
}
fi
complete -o default -F _module module
|