diff options
author | Oliver Kiddle <opk@users.sourceforge.net> | 2002-09-03 12:25:51 +0000 |
---|---|---|
committer | Oliver Kiddle <opk@users.sourceforge.net> | 2002-09-03 12:25:51 +0000 |
commit | efa93741d70075362f7979d23a59786a3f78bbe3 (patch) | |
tree | 9cf56e317c6056b29984e71d64002ab84ed2337e /Completion/Linux/Command | |
parent | e875dd2db9098d3448fe02129fc4a75b040d37a8 (diff) | |
download | zsh-efa93741d70075362f7979d23a59786a3f78bbe3.tar.gz zsh-efa93741d70075362f7979d23a59786a3f78bbe3.tar.xz zsh-efa93741d70075362f7979d23a59786a3f78bbe3.zip |
moved from Completion/Unix/Command/_modutils
Diffstat (limited to 'Completion/Linux/Command')
-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 |