2019-04-05 12:41:35 +03:00
#compdef bootctl -*- shell-script -*-
2017-11-18 20:21:19 +03:00
# SPDX-License-Identifier: LGPL-2.1+
2013-11-14 08:02:23 +04:00
2019-09-12 20:13:13 +03:00
__bootctl() {
bootctl --no-pager $@ 2>/dev/null
}
_bootctl_comp_ids() {
local expl
local -a ids
__bootctl list | while read a b; do
if [[ "$a" == "id:" ]]; then
ids+="$b"
fi
done
_wanted id expl 'boot id' compadd "$@" -a ids
}
_bootctl_set-default() {
_bootctl_comp_ids
}
_bootctl_set-oneshot() {
_bootctl_comp_ids
}
2018-12-24 14:15:38 +03:00
(( $+functions[_bootctl_commands] )) || _bootctl_commands()
2013-11-14 08:02:23 +04:00
{
local -a _bootctl_cmds
_bootctl_cmds=(
2015-05-24 14:25:52 +03:00
"status:Show status of installed systemd-boot and EFI variables"
2015-06-01 13:06:07 +03:00
"install:Install systemd-boot to the ESP and EFI variables"
2015-05-24 14:25:52 +03:00
"update:Update systemd-boot in the ESP and EFI variables"
"remove:Remove systemd-boot from the ESP and EFI variables"
2019-09-12 20:13:13 +03:00
"random-seed:Initialize random seed in ESP and EFI variables"
"is-installed:Test whether systemd-boot is installed in the ESP"
"set-default:Set the default boot loader entry"
"set-oneshot:Set the default boot loader entry only for the next boot"
2013-11-14 08:02:23 +04:00
)
if (( CURRENT == 1 )); then
_describe -t commands 'bootctl command' _bootctl_cmds || compadd "$@"
else
local curcontext="$curcontext"
cmd="${${_bootctl_cmds[(r)$words[1]:*]%%:*}}"
if (( $+functions[_bootctl_$cmd] )); then
_bootctl_$cmd
else
_message "no more options"
fi
fi
}
_arguments \
{-h,--help}'[Prints a short help text and exits.]' \
'--version[Prints a short version string and exits.]' \
2019-09-12 20:13:13 +03:00
'--esp-path=[Path to the EFI System Partition (ESP)]:path:_directories' \
'--boot-path=[Path to the $BOOT partition]:path:_directories' \
{-p,--print-esp-path}'[Print path to the EFI system partition]' \
{-x,--print-boot-path}'[Print path to the $BOOT partition]' \
2015-05-24 14:25:52 +03:00
'--no-variables[Do not touch EFI variables]' \
2019-09-12 20:13:13 +03:00
'--no-pager[Do not pipe output into a pager]' \
2018-12-24 14:15:38 +03:00
'*::bootctl command:_bootctl_commands'