]> git.ipfire.org Git - thirdparty/dracut.git/blame - dracut-bash-completion.sh
Fix a missing space in example configs
[thirdparty/dracut.git] / dracut-bash-completion.sh
CommitLineData
336bd09d 1#
917f3e4d
HH
2# Copyright 2013 Red Hat, Inc. All rights reserved.
3#
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.
8#
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.
13#
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/>.
16#
17
18__contains_word () {
19 local word=$1; shift
20 for w in $*; do [[ $w = $word ]] && return 0; done
21 return 1
22}
23
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
da97807c 32 --xz --zstd --no-compress --gzip --list-modules --show-modules --keep
5bbfd484 33 --printsize --regenerate-all --noimageifnotneeded --early-microcode
d00cfc2a 34 --no-early-microcode --print-cmdline --reproducible --uefi'
917f3e4d
HH
35
36 [ARG]='-a -m -o -d -I -k -c -L --kver --add --force-add --add-drivers
37 --omit-drivers --modules --omit --drivers --filesystems --install
38 --fwdir --libdirs --fscks --add-fstab --mount --device --nofscks
39 --kmoddir --conf --confdir --tmpdir --stdlog --compress --prefix
37383f71 40 --kernel-cmdline --sshkey --persistent-policy --install-optional
636d2d46 41 --loginstall --uefi-stub --kernel-image
37383f71 42 '
917f3e4d
HH
43 )
44
45 if __contains_word "$prev" ${OPTS[ARG]}; then
46 case $prev in
46a885bf 47 --kmoddir|-k|--fwdir|--confdir|--tmpdir)
917f3e4d
HH
48 comps=$(compgen -d -- "$cur")
49 compopt -o filenames
50 ;;
54b68829 51 -c|--conf|--sshkey|--add-fstab|--add-device|-I|--install|--install-optional)
46a885bf
HH
52 comps=$(compgen -f -- "$cur")
53 compopt -o filenames
54 ;;
917f3e4d
HH
55 -a|-m|-o|--add|--modules|--omit)
56 comps=$(dracut --list-modules 2>/dev/null)
57 ;;
324ea606
HH
58 --persistent-policy)
59 comps=$(cd /dev/disk/; echo *)
60 ;;
fb05f987 61 --kver)
46a885bf 62 comps=$(cd /lib/modules; echo [0-9]*)
fb05f987 63 ;;
917f3e4d
HH
64 *)
65 return 0
66 ;;
67 esac
68 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
69 return 0
70 fi
71
72 if [[ $cur = -* ]]; then
73 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
74 return 0
75 fi
76}
77
78complete -F _dracut dracut