about summary refs log tree commit diff
path: root/Completion/Unix/Command/_modutils
blob: 42481834b184a01cb1c1521bb78340e18af929a6 (plain) (blame)
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
#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