1
# bash completion for Linux module-init-tools
3
# Linux rmmod(8) completion. This completes on a list of all currently
4
# installed kernel modules.
12
_get_comp_words_by_ref cur
14
_installed_modules "$cur"
17
complete -F _rmmod rmmod
19
# Linux insmod(8), modprobe(8) and modinfo(8) completion. This completes on a
20
# list of all available modules for the version of the kernel currently
23
have insmod || have modprobe || have modinfo &&
26
local cur prev modpath
29
_get_comp_words_by_ref cur prev
31
# behave like lsmod for modprobe -r
32
if [[ ${1##*/} == modprobe && "${COMP_WORDS[1]}" == -r ]]; then
33
_installed_modules "$cur"
37
# do filename completion if we're giving a path to a module
38
if [[ "$cur" == */* ]]; then
39
_filedir '@(?(k)o?(.gz))'
43
if [[ $COMP_CWORD -gt 1 && "${COMP_WORDS[COMP_CWORD-1]}" != -* ]]; then
44
# do module parameter completion
45
COMPREPLY=( $( compgen -W "$( /sbin/modinfo -p ${COMP_WORDS[1]} | \
46
cut -d: -f1 )" -- "$cur" ) )
53
complete -F _insmod -o filenames insmod modprobe modinfo
58
# sh-indent-comment: t
59
# indent-tabs-mode: nil
61
# ex: ts=4 sw=4 et filetype=sh