summaryrefslogtreecommitdiffstats
path: root/bash-completion
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2013-11-26 17:09:49 +0100
committerDave Reisner <dreisner@archlinux.org>2013-11-26 17:09:49 +0100
commita1e50f04b89ff042baf91a403a6df0cbd1e3cec2 (patch)
treede9bbad0fd84f35a6e56a8f28f809a5e7776cc24 /bash-completion
parent2fa0eb25d47c920c18e7d2498c647a801d836596 (diff)
downloadmkinitcpio-a1e50f04b89ff042baf91a403a6df0cbd1e3cec2.tar.gz
mkinitcpio-a1e50f04b89ff042baf91a403a6df0cbd1e3cec2.tar.xz
move a bunch of stuff to subdirs
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'bash-completion')
-rw-r--r--bash-completion84
1 files changed, 0 insertions, 84 deletions
diff --git a/bash-completion b/bash-completion
deleted file mode 100644
index a0f07dc..0000000
--- a/bash-completion
+++ /dev/null
@@ -1,84 +0,0 @@
-#!/bin/bash
-
-_detect_kver() {
- local kver_validator='^[[:digit:]]+(\.[[:digit:]]+)+'
- offset=$(hexdump -s 526 -n 2 -e '"%0d"' "$1" 2>/dev/null) || return 1
- read kver _ < \
- <(dd if="$1" bs=1 count=127 skip=$(( offset + 0x200 )) 2>/dev/null)
- [[ $kver =~ $kver_validator ]] && printf "$kver"
-}
-
-_lsinitcpio() {
- local cur opts
- opts=(-a --analyze -c --config -h --help -l --list
- -n --nocolor -V --version -v --verbose -x --extract)
-
- _get_comp_words_by_ref cur
-
- case $cur in
- -*)
- COMPREPLY=($(compgen -W "${opts[*]}" -- "$cur")) ;;
- *)
- _filedir ;;
- esac
-}
-
-_find_kernel_versions() {
- local -a matches
- local dir f kver
-
- for f in /boot/*; do
- # only match regular files which pass validation
- if [[ ! -L $f && -f $f ]] && kver=$(_detect_kver "$f"); then
- matches+=("$f" "$kver")
- fi
- done
-
- COMPREPLY=($(compgen -W "${matches[*]}" -- $cur))
-}
-
-_files_from_dirs() {
- local files stripsuf d f
-
- if [[ $1 = -s ]]; then
- stripsuf=$2
- shift 2
- fi
-
- for d in "$@"; do
- for f in "$d"/*; do
- [[ -f $f ]] && files+=("${f##*/}")
- done
- done
-
- printf '%s\n' "${files[@]%$stripsuf}"
-}
-
-_mkinitcpio() {
- local action cur prev opts
- opts=(-A --addhooks -c --config -g --generate -H --hookhelp -h --help -k --kernel
- -L --listhooks -M --automods -n --nocolor -P --allpresets -p --preset -r --moduleroot
- -S --skiphooks -s --save -t --builddir -V --version -v --verbose -z --compress)
-
- _get_comp_words_by_ref cur prev
-
- case $prev in
- -[cg]|--config|--generate)
- _filedir ;;
- -r|--moduleroot|-t|--builddir)
- _filedir -d ;;
- -k|--kernel)
- _find_kernel_versions ;;
- -p|--preset)
- COMPREPLY=($(compgen -W "$(_files_from_dirs -s .preset /etc/mkinitcpio.d)" -- "$cur")) ;;
- -[AHS]|--add|--hookhelp|--skiphooks)
- COMPREPLY=($(compgen -W "$(_files_from_dirs {/usr,}/lib/initcpio/install)" -- "$cur")) ;;
- *)
- COMPREPLY=($(compgen -W "${opts[*]}" -- "$cur")) ;;
- esac
-}
-
-complete -F _mkinitcpio mkinitcpio
-complete -F _lsinitcpio lsinitcpio
-
-# vim: set et ts=4 sw=4 ft=sh: