1 # bootctl(1) completion -*- shell-script -*-
2 # SPDX-License-Identifier: LGPL-2.1+
4 # This file is part of systemd.
6 # systemd is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU Lesser General Public License as published by
8 # the Free Software Foundation; either version 2.1 of the License, or
9 # (at your option) any later version.
11 # systemd is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public License
17 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 local w word=$1; shift
22 [[ $w = "$word" ]] && return
27 bootctl --no-pager list 2>/dev/null | { while read -r a b; do [[ $a == 'id:' ]] && echo " $b"; done }
32 local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
34 [STANDALONE]='-h --help --no-variables -p --print-esp-path -x --print-boot-path --version --no-pager'
35 [ARG]='--esp-path --boot-path'
38 if __contains_word "$prev" ${OPTS[ARG]}; then
40 --esp-path|--boot-path)
41 if [[ -z $cur ]]; then
42 comps=$(compgen -A directory -- "/" )
44 comps=$(compgen -A directory -- "$cur" )
49 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
53 if [[ "$cur" = -* ]]; then
54 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
59 [STANDALONE]='help install list remove status update'
60 [BOOTENTRY]='set-default set-oneshot'
63 for ((i=0; i < COMP_CWORD; i++)); do
64 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then
70 if [[ -z $verb ]]; then
72 elif __contains_word "$verb" ${VERBS[STANDALONE]}; then
74 elif __contains_word "$verb" ${VERBS[BOOTENTRY]}; then
76 for ((i++; i < COMP_CWORD; i++)); do
77 if ! __contains_word "${COMP_WORDS[i]}" ${OPTS[*]} ${VERBS[*]} &&
78 ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
84 if [[ -z $name ]]; then
85 comps=$( __get_entry_ids )
91 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
95 complete -F _bootctl bootctl