summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2011-06-27 05:06:55 +0200
committerDave Reisner <dreisner@archlinux.org>2011-06-30 20:17:37 +0200
commit7f2b324b93bb152f5b9a1be6d15f12a46e5e9360 (patch)
treedfa49cffd32ae3c113d9e5325ba2f750a495155b
parentfe2c62c3c34f67b9acc14297b00120e6f38da44d (diff)
downloadmkinitcpio-7f2b324b93bb152f5b9a1be6d15f12a46e5e9360.tar.gz
mkinitcpio-7f2b324b93bb152f5b9a1be6d15f12a46e5e9360.tar.xz
bash-completion: complete -k on kernel images
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
-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));;