1 # bootctl(1) completion -*- shell-script -*-
2 # SPDX-License-Identifier: LGPL-2.1+
4 # This file is part of systemd.
7 # systemd is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU Lesser General Public License as published by
9 # the Free Software Foundation; either version 2.1 of the License, or
10 # (at your option) any later version.
12 # systemd is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public License
18 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
21 local w word=$1; shift
23 [[ $w = "$word" ]] && return
28 bootctl --no-pager list 2>/dev/null | { while read -r a b; do [[ $a == 'id:' ]] && echo " $b"; done }
33 local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
35 [STANDALONE]='-h --help --no-variables -p --print-path --version --no-pager'
39 if __contains_word "$prev" ${OPTS[ARG]}; then
42 if [[ -z $cur ]]; then
43 comps=$(compgen -A directory -- "/" )
45 comps=$(compgen -A directory -- "$cur" )
50 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
54 if [[ "$cur" = -* ]]; then
55 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
60 [STANDALONE]='help install list remove status update'
61 [BOOTENTRY]='set-default set-oneshot'
64 for ((i=0; i < COMP_CWORD; i++)); do
65 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then
71 if [[ -z $verb ]]; then
73 elif __contains_word "$verb" ${VERBS[STANDALONE]}; then
75 elif __contains_word "$verb" ${VERBS[BOOTENTRY]}; then
77 for ((i++; i < COMP_CWORD; i++)); do
78 if ! __contains_word "${COMP_WORDS[i]}" ${OPTS[*]} ${VERBS[*]} &&
79 ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
85 if [[ -z $name ]]; then
86 comps=$( __get_entry_ids )
92 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
96 complete -F _bootctl bootctl