dracut.spec: move dmsquash and livnet to subpackage
[dracut.git] / dracut-bash-completion.sh
blob09330a67323082214718f1f95fbf2791018e075d
2 # Copyright 2013 Red Hat, Inc. All rights reserved.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 __contains_word () {
19 local word=$1; shift
20 for w in $*; do [[ $w = $word ]] && return 0; done
21 return 1
24 _dracut() {
25 local field_vals= cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
26 local -A OPTS=(
27 [STANDALONE]='-f -v -q -l -H -h -M -N
28 --ro-mnt --force --kernel-only --no-kernel --strip --nostrip
29 --hardlink --nohardlink --noprefix --mdadmconf --nomdadmconf
30 --lvmconf --nolvmconf --debug --profile --verbose --quiet
31 --local --hostonly --no-hostonly --fstab --help --bzip2 --lzma
32 --xz --no-compress --gzip --list-modules --show-modules --keep
33 --printsize --regenerate-all --noimageifnotneeded --early-microcode
34 --no-early-microcode --print-cmdline --prelink --noprelink --reproducible
35 --uefi
38 [ARG]='-a -m -o -d -I -k -c -L --kver --add --force-add --add-drivers
39 --omit-drivers --modules --omit --drivers --filesystems --install
40 --fwdir --libdirs --fscks --add-fstab --mount --device --nofscks
41 --kmoddir --conf --confdir --tmpdir --stdlog --compress --prefix
42 --kernel-cmdline --sshkey --persistent-policy --install-optional
43 --loginstall --uefi-stub --kernel-image
47 if __contains_word "$prev" ${OPTS[ARG]}; then
48 case $prev in
49 --kmoddir|-k|--fwdir|--confdir|--tmpdir)
50 comps=$(compgen -d -- "$cur")
51 compopt -o filenames
53 -c|--conf|--sshkey|--add-fstab|--add-device|-I|--install|--install-optional)
54 comps=$(compgen -f -- "$cur")
55 compopt -o filenames
57 -a|-m|-o|--add|--modules|--omit)
58 comps=$(dracut --list-modules 2>/dev/null)
60 --persistent-policy)
61 comps=$(cd /dev/disk/; echo *)
63 --kver)
64 comps=$(cd /lib/modules; echo [0-9]*)
67 return 0
69 esac
70 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
71 return 0
74 if [[ $cur = -* ]]; then
75 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
76 return 0
80 complete -F _dracut dracut