about summary refs log tree commit diff
path: root/Completion/Linux/Command/_modutils
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Linux/Command/_modutils')
-rw-r--r--Completion/Linux/Command/_modutils12
1 files changed, 11 insertions, 1 deletions
diff --git a/Completion/Linux/Command/_modutils b/Completion/Linux/Command/_modutils
index 3213524d7..879f64271 100644
--- a/Completion/Linux/Command/_modutils
+++ b/Completion/Linux/Command/_modutils
@@ -1,6 +1,7 @@
 #compdef lsmod modinfo modprobe rmmod insmod
 
 local curcontext="$curcontext" expl state line modules ign args ret=1
+local -r modules_dir=/lib/modules
 
 args=(
   '(-)'{-V,--version}'[print version]'
@@ -19,6 +20,8 @@ case "$service" in
       '(-)'{-p,--parameters}'[display the typed parameters that a module may support]' \
       '(-)'{-F,--field}"[display only selected module's information]:module_field:(
         alias author depends description filename license parm)" \
+      '(-)-k[use modules from a different kernel version]:kernel_version:(
+        $(echo $modules_dir/*(/\:t)))' \
       '1:module file:->all_modules' && ret=0
   ;;
 
@@ -77,7 +80,14 @@ case "$state" in
   ;&
 
   all_modules)
-    modules=( /lib/modules/$(uname -r)/(*~source)/**/*(.:t:r) )
+    local kver
+    integer kver_idx
+    if (( kver_idx=${words[(I)-k]} )); then
+      kver=${words[kver_idx+1]}
+    else
+      kver=$(uname -r)
+    fi
+    modules=( $modules_dir/$kver/(*~source)/**/*(.:t:r) )
 
     if [[ $state = loadable_modules ]]; then
         modules=( ${modules:#(${(j:|:)~${=loaded_modules//_/-}})} )