about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Unix/Command/.distfiles2
-rwxr-xr-xCompletion/Unix/Command/_modutils44
2 files changed, 45 insertions, 1 deletions
diff --git a/Completion/Unix/Command/.distfiles b/Completion/Unix/Command/.distfiles
index 1ce9843b8..bed529902 100644
--- a/Completion/Unix/Command/.distfiles
+++ b/Completion/Unix/Command/.distfiles
@@ -14,5 +14,5 @@ _cvs          _gnu_generic  _ls           _perl         _tar          _zip
 _dd           _gprof        _lynx         _perldoc      _telnet       _pine
 _dict         _grep         _lzop         _prcs         _tiff         _elm
 _diff         _gs           _make         _psutils      _tin	_apm  _mail
-_loadkeys
+_loadkeys     _modutils
 '
diff --git a/Completion/Unix/Command/_modutils b/Completion/Unix/Command/_modutils
new file mode 100755
index 000000000..42481834b
--- /dev/null
+++ b/Completion/Unix/Command/_modutils
@@ -0,0 +1,44 @@
+#compdef modprobe rmmod
+
+local loaded
+
+_modutils_loaded_modules() {
+
+if [[ -f /proc/modules ]]; then
+ loaded=(${${(f)"$(</proc/modules)"}%% *})
+elif [[ -x /sbin/lsmod ]]; then
+ loaded=(${${${(f)"$(</sbin/lsmod)"}%% *}%Module})
+else
+ return 1
+fi
+
+compadd -a loaded
+return 0
+}
+
+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'
+  ;;
+
+  modprobe)
+  _arguments '(--remove)-r[remove]:loaded module:_modutils_loaded_modules' \
+             '(-r)--remove:loaded module:_modutils_loaded_modules'
+  ;;
+
+esac