From 81725e6ff3bbde89fc10fb8f25e78ee67074ae25 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sat, 12 Nov 2011 22:58:15 -0500 Subject: update bash completion - change scavenging of /lib/modules to avoid grabbing extramodules dirs - add missing options for lsinitcpio and mkinitcpio - use _filedir for completing -b Signed-off-by: Dave Reisner --- bash-completion | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/bash-completion b/bash-completion index 8caff93..ee544ec 100644 --- a/bash-completion +++ b/bash-completion @@ -3,7 +3,7 @@ _lsinitcpio() { local action cur - action="-a -h -v -x" + action="-a -h -n -v -x" _get_comp_words_by_ref cur case "$cur" in -*) COMPREPLY=($(compgen -W "${action}" -- "$cur"));; @@ -15,24 +15,30 @@ _find_kernel_versions() { local -a matches local regex + # add completions from kernels in /boot 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)) + # add completions based on kernel versions in /lib/modules + for dir in /lib/modules/*/kernel; do + dir=${dir%/kernel} + matches+=("${dir#/lib/modules/}") + done + + COMPREPLY=($(compgen -W "${matches[*]}" -- $cur)) } _mkinitcpio() { local action cur prev - action="-c -k -s -b -g -p -S -v -M -L -H -h" + action="-b -c -g -H -h -k -L -M -n -p -S -s -v -z" _get_comp_words_by_ref cur prev case "$prev" in -c|-g) _filedir;; -k) _find_kernel_versions;; - -b) COMPREPLY=($(compgen -d "$cur" -- $cur));; + -b) _filedir -d;; -p) COMPREPLY=($(cd /etc/mkinitcpio.d/ && compgen -X '!*.preset' -f -- $cur)) COMPREPLY=("${COMPREPLY[@]%.preset}");; -H|-S) COMPREPLY=($(cd /lib/initcpio/install/ && compgen -f -- $cur));; -- cgit v1.2.3-24-g4f1b