summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bash-completion16
1 files changed, 15 insertions, 1 deletions
diff --git a/bash-completion b/bash-completion
index f4f8181..2a53c1a 100644
--- a/bash-completion
+++ b/bash-completion
@@ -11,6 +11,20 @@ _lsinitcpio ()
esac
}
+_find_kernel_versions() {
+ local -a matches
+ local regex
+
+ regex="Linux kernel.*version"
+ while IFS=':' read -r file metadata; do
+ [[ $metadata =~ $regex ]] || continue
+ matches+=("$file")
+ done < <(file -e ascii /boot/*)
+
+ COMPREPLY=($(cd /lib/modules && compgen -d -- $cur)
+ $(compgen -W "${matches[*]}" -- $cur))
+}
+
_mkinitcpio ()
{
local action cur prev
@@ -18,7 +32,7 @@ _mkinitcpio ()
_get_comp_words_by_ref cur prev
case "$prev" in
-c|-g) _filedir;;
- -k) COMPREPLY=($(cd /lib/modules && compgen -d -- $cur));;
+ -k) _find_kernel_versions;;
-b) COMPREPLY=($(compgen -d "$cur" -- $cur));;
-p) COMPREPLY=($(cd /etc/mkinitcpio.d/ && compgen -X '!*.preset' -f -- $cur|sed 's/\.preset//'));;
-H|-S) COMPREPLY=($(cd /lib/initcpio/install/ && compgen -f -- $cur));;