blob: b034cc724184fc0a5df531782e52b21ca60ad6d9 (
plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
#compdef modprobe
## completion for modprobe x.y, based on modprobe(1)
## Copyright (C) 2010 by Birte Friesel <derf@chaosdorf.de>
## License: WTFPL <http://sam.zoy.org/wtfpl>:
## 0. You just DO WHAT THE FUCK YOU WANT TO.
##
## http://finalrewind.org/git/zsh/plain/etc/completions/_modprobe
typeset -a arguments
typeset -A argument_pairs argument_postfix
typeset arg
argument_pairs=(
all a
use-blacklist b
config C
showconfig c
dirname d
force f
ignore-install i
list l
dry-run n
name o
quiet q
resolve-alias R
remove r
set-version S
syslog s
version V
verbose v
)
argument_postfix=(
all '[Insert all modules listed, no parameters]'
use-blacklist '[Apply blacklist commands to module names]'
config '[Change config directory/file]:file:_files]'
showconfig '[Dump current configuration]'
dirname '[Set module directory]:module directory:_files -/'
force '[Force module insertion regardless of version issues]'
ignore-install '[Ignore install and remove commands in the config]'
list '[List all matching modules]:wildcard'
dry-run '[Do not actually change things]'
name '[insert module with another name]:module name'
quiet '[Do not print error messages]'
resolve-alias '[Print all module names matching an alias]'
remove '[remove modules rather than inserting them]'
set-version '[Set kernel version (for finding modules)]'
syslog '[Write errors to syslog]'
version '[show version information]'
verbose '[Show what modprobe is doing]'
)
arguments=(
'--dump-modversions[Print versioning information]'
'--first-time[fail if a module already is inserted]'
'--force-vermagic[Ignore version magic when loading modules]'
'--force-modversion[Ignore CONFIG_MODVERSION when loading modules]'
'--show-depends[List dependencies of a module]'
':module:_modprobe_module'
'*:module name or argument:_modprobe_module_or_arg'
)
for arg in ${(k)argument_pairs}; {
arguments+='(--'${arg}')-'${argument_pairs[$arg]}${argument_postfix[$arg]}
arguments+='(-'${${argument_pairs[$arg]}[1]}')--'${arg}${argument_postfix[$arg]}
}
function _modprobe_all_modules {
typeset expl
_wanted module expl module \
compadd ${$(echo /lib/modules/$(uname -r)/**/*.ko):t:r}
}
function _modprobe_loaded_modules {
typeset expl
_wanted module expl module \
compadd $(cut -d\ -f1 < /proc/modules)
}
function _modprobe_module_args {
_message 'module arguments'
}
function _modprobe_module {
if [[ ${words[(I)(-r|--remove)]} == 0 ]] {
_modprobe_all_modules
} else {
_modprobe_loaded_modules
}
}
function _modprobe_module_or_arg {
if [[ ${words[(I)(-a|--all)]} == 0 ]] {
_modprobe_module_args
} else {
_modprobe_module
}
}
_arguments -s ${arguments}
|