diff options
author | Oliver Kiddle <opk@users.sourceforge.net> | 2002-09-26 11:59:39 +0000 |
---|---|---|
committer | Oliver Kiddle <opk@users.sourceforge.net> | 2002-09-26 11:59:39 +0000 |
commit | 9a8f7d979bea9e082c6ccd84f29973f40b6c7e7c (patch) | |
tree | 6b48c4b769743e9f92d2f43e1bb4dbc4710d74eb /Completion/Linux/Command/_modutils | |
parent | 105e3e78b60f9f3e9ca1b75e8620e8212c9f75eb (diff) | |
download | zsh-9a8f7d979bea9e082c6ccd84f29973f40b6c7e7c.tar.gz zsh-9a8f7d979bea9e082c6ccd84f29973f40b6c7e7c.tar.xz zsh-9a8f7d979bea9e082c6ccd84f29973f40b6c7e7c.zip |
moved from Completion/Unix/Command/_modutils
Diffstat (limited to 'Completion/Linux/Command/_modutils')
-rw-r--r-- | Completion/Linux/Command/_modutils | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/Completion/Linux/Command/_modutils b/Completion/Linux/Command/_modutils new file mode 100644 index 000000000..1b47e8a3d --- /dev/null +++ b/Completion/Linux/Command/_modutils @@ -0,0 +1,87 @@ +#compdef modprobe rmmod + +local curcontext="$curcontext" state line expl loaded + +_modutils_loaded_modules() { + +if [[ -r /proc/modules ]]; then + loaded=(${${(f)"$(</proc/modules)"}%% *}) +elif [[ -x /sbin/lsmod ]]; then + loaded=(${${(f)"$(/sbin/lsmod)"}[2,-1]%% *}) +else + return 1 +fi + +_wanted modules expl 'loaded module' compadd -a loaded +} + +case "$service" in + rmmod) + + _arguments '(--all)-a[remove all unused autocleanable modules]' \ + '(-a)--all' \ + '(--persist)-e[save persistent data]' \ + '(-e)--persist' \ + '(--help)-h[print help text]' \ + '(-h)--help' \ + '(--stacks)-r[remove a module stack]' \ + '(-r)--stacks' \ + '(--syslog)-s[output to syslog]' \ + '(-s)--syslog' \ + '(--verbose)-v[be verbose]' \ + '(-v)--verbose' \ + '(--version)-V[print version]' \ + '(-V)--version' \ + '*:loaded module:_modutils_loaded_modules' && return 0 + ;; + + modprobe) + + _modprobe_arguments=( + '(--all)-a[all]' \ + '(-a)--all' \ + '(--showconfig)-c[showconfig]' \ + '(-c)--showconfig' \ + '(--debug)-d[debug]' \ + '(-d)--debug' \ + '(--autoclean)-k[set autoclean]' \ + '(-k)--autoclean' \ + '(--show)-n[do not act]' \ + '(-n)--show' \ + '(--quiet)-q[do not complain about insmod failures]' \ + '(-q)--quiet' \ + '(--syslog)-s[report via syslog instead of stderr]' \ + '(-s)--syslog' \ + '(--type)-t[module type]:moduletype:' \ + '(-t)--type:moduletype:' \ + '(--verbose)-v[print all commands as executed]' \ + '(-v)--verbose' \ + '(--version)-V[show release version]' \ + '(-V)--version' \ + '(--config)-C[config file]:config file:_files' \ + '(-C)--config:config file:_files' + ) + + _arguments -C '(--remove)-r[remove]:*:loaded module:->modprobe_remove' \ + '(-r)--remove:*:loaded module:->modprobe_remove' \ + '(--list)-l[list matching modules]:*:module file:->modprobe_list' \ + '(-l)--list:*:module file:->modprobe_list' \ + "$_modprobe_arguments[@]" && return 0 + + ;; + +esac + +case "$state" in + modprobe_remove) + _call_function ret _modutils_$state && return ret + _arguments "$_modprobe_arguments[@]" \ + '*:loaded module:_modutils_loaded_modules' + ;; + + modprobe_list) + _call_function ret _modutils_$state && return ret + _arguments "$_modprobe_arguments[@]" \ + '*:module file:compadd ${^${(M)${(f)"$(modprobe -c)"}:#path*}#*[=]}/**/*.o(:t)' + +esac |