diff options
Diffstat (limited to 'Completion')
-rw-r--r-- | Completion/Linux/Command/_modutils | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/Completion/Linux/Command/_modutils b/Completion/Linux/Command/_modutils index 732290363..e03b47184 100644 --- a/Completion/Linux/Command/_modutils +++ b/Completion/Linux/Command/_modutils @@ -36,7 +36,7 @@ case "$service" in '(-C --config)'{-C,--config}'[specify config file]:config file:_files' \ "(-r --remove -l --list -t --type -a --all $ign)"{-r,--remove}'[remove module (stacks)]' \ "(* -l --list -r --remove $ign)"{-l,--list}'[list matching modules]' \ - "(-c $ign)1:modules:->all_modules" \ + "(-c $ign)1:modules:->loadable_modules" \ "(-c -l --list -t --type $ign)*:params:->params" && ret=0 [[ -n $state ]] && (( $+opt_args[-r] )) && state=loaded_modules @@ -60,23 +60,31 @@ case "$service" in esac case "$state" in - loaded_modules) + loaded_modules|loadable_modules) if [[ -r /proc/modules ]]; then - modules=(${${(f)"$(</proc/modules)"}%% *}) + loaded_modules=(${${(f)"$(</proc/modules)"}%% *}) elif [[ -x /sbin/lsmod ]]; then - modules=(${${(f)"$(/sbin/lsmod)"}[2,-1]%% *}) + loaded_modules=(${${(f)"$(/sbin/lsmod)"}[2,-1]%% *}) else return 1 fi - - _wanted modules expl 'loaded module' compadd -a modules && return - ;; + + if [[ $state = loaded_modules ]]; then + _wanted modules expl 'loaded module' compadd -a loaded_modules && return + return ret + fi + ;& all_modules) modules=( ${${${${(f)"$(_call_program modules ${(M)words[1]##*/}modprobe -l 2>/dev/null)"}:#}##*/}%%.*} ) + + if [[ $state = loadable_modules ]]; then + modules=( ${modules:#(${(j:|:)~${=loaded_modules//_/-}})} ) + fi + _tags files modules while _tags; do - _requested files expl "module file" _files && ret=0 + _requested files expl "module file" _files -g '*.ko' && ret=0 _requested modules expl module compadd -a modules && ret=0 done ;; |