| 1 |
#compdef bootctl |
| 2 |
# SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 |
|
| 4 |
__bootctl() { |
| 5 |
bootctl --no-pager $@ 2>/dev/null |
| 6 |
} |
| 7 |
|
| 8 |
_bootctl_comp_ids() { |
| 9 |
local expl |
| 10 |
local -a ids |
| 11 |
__bootctl list | while read -r a b; do |
| 12 |
if [[ "$a" == "id:" ]]; then |
| 13 |
ids+="$b" |
| 14 |
fi |
| 15 |
done |
| 16 |
_wanted id expl 'boot id' compadd "$@" -a ids |
| 17 |
} |
| 18 |
|
| 19 |
_bootctl_set-default() { |
| 20 |
_bootctl_comp_ids |
| 21 |
} |
| 22 |
|
| 23 |
_bootctl_set-oneshot() { |
| 24 |
_bootctl_comp_ids |
| 25 |
} |
| 26 |
|
| 27 |
_bootctl_set-sysfail() { |
| 28 |
_bootctl_comp_ids |
| 29 |
} |
| 30 |
|
| 31 |
_bootctl_set-preferred() { |
| 32 |
_bootctl_comp_ids |
| 33 |
} |
| 34 |
|
| 35 |
_bootctl_unlink() { |
| 36 |
_bootctl_comp_ids |
| 37 |
} |
| 38 |
|
| 39 |
_bootctl_link() { |
| 40 |
_files |
| 41 |
} |
| 42 |
|
| 43 |
_bootctl_kernel-identify() { |
| 44 |
_files |
| 45 |
} |
| 46 |
|
| 47 |
_bootctl_kernel-inspect() { |
| 48 |
_files |
| 49 |
} |
| 50 |
|
| 51 |
_bootctl_reboot-to-firmware() { |
| 52 |
local -a _completions |
| 53 |
_completions=( yes no ) |
| 54 |
typeset -U _completions |
| 55 |
_describe 'possible values' _completions |
| 56 |
} |
| 57 |
|
| 58 |
(( $+functions[_bootctl_commands] )) || _bootctl_commands() |
| 59 |
{ |
| 60 |
local -a _bootctl_cmds |
| 61 |
_bootctl_cmds=( |
| 62 |
"status:Show status of installed systemd-boot and EFI variables" |
| 63 |
"install:Install systemd-boot to the ESP and EFI variables" |
| 64 |
"update:Update systemd-boot in the ESP and EFI variables" |
| 65 |
"remove:Remove systemd-boot from the ESP and EFI variables" |
| 66 |
"is-installed:Test whether systemd-boot is installed in the ESP" |
| 67 |
"random-seed:Initialize random seed in ESP and EFI variables" |
| 68 |
"reboot-to-firmware:Query or set reboot-to-firmware EFI flag" |
| 69 |
"list:List boot loader entries" |
| 70 |
"set-default:Set the default boot loader entry" |
| 71 |
"set-oneshot:Set the default boot loader entry only for the next boot" |
| 72 |
"set-sysfail:Set boot loader entry used in case of a system failure" |
| 73 |
"set-preferred:Set the preferred boot loader entry" |
| 74 |
"set-timeout:Set the menu timeout" |
| 75 |
"set-timeout-oneshot:Set the menu timeout for the next boot only" |
| 76 |
"unlink:Remove boot loader entry" |
| 77 |
"link:Add boot loader entry" |
| 78 |
"cleanup:Remove files in ESP not referenced in any boot entry" |
| 79 |
"kernel-identify:Identify kernel image type" |
| 80 |
"kernel-inspect:Print details about the kernel image" |
| 81 |
) |
| 82 |
if (( CURRENT == 1 )); then |
| 83 |
_describe -t commands 'bootctl command' _bootctl_cmds || compadd "$@" |
| 84 |
else |
| 85 |
local curcontext="$curcontext" |
| 86 |
cmd="${${_bootctl_cmds[(r)$words[1]:*]%%:*}}" |
| 87 |
if (( $+functions[_bootctl_$cmd] )); then |
| 88 |
_bootctl_$cmd |
| 89 |
else |
| 90 |
_message "no more options" |
| 91 |
fi |
| 92 |
fi |
| 93 |
} |
| 94 |
|
| 95 |
_arguments \ |
| 96 |
'(- *)'{-h,--help}'[Prints a short help text and exits.]' \ |
| 97 |
'(- *)--version[Prints a short version string and exits.]' \ |
| 98 |
'--esp-path=[Path to the EFI System Partition (ESP)]:path:_directories' \ |
| 99 |
'--boot-path=[Path to the $BOOT partition]:path:_directories' \ |
| 100 |
'(-p --print-esp-path)'{-p,--print-esp-path}'[Print path to the EFI system partition]' \ |
| 101 |
'(-x --print-boot-path)'{-x,--print-boot-path}'[Print path to the $BOOT partition]' \ |
| 102 |
'--print-efi-architecture[Print the EFI architecture identifier]' \ |
| 103 |
'--make-machine-id-directory=[Control creation and deletion of the top-level machine ID directory.]:options:(yes no auto)' \ |
| 104 |
'--no-pager[Do not pipe output into a pager]' \ |
| 105 |
'--graceful[Do not fail when locating ESP or writing fails]' \ |
| 106 |
'--dry-run[Dry run (unlink and cleanup)]' \ |
| 107 |
'--oldest=[Delete oldest boot menu entry]:options:(yes no)' \ |
| 108 |
'--root=[Operate under the specified directory]:PATH' \ |
| 109 |
'--image=[Operate on the specified image]:PATH' \ |
| 110 |
'--install-source[Where to pick files when using --root=/--image=]:options:(image host auto)' \ |
| 111 |
'--random-seed[Whether to create random-seed file during install]:options:(yes no)' \ |
| 112 |
'--variables=[Touch EFI variables]:options:(yes no)' \ |
| 113 |
'*::bootctl command:_bootctl_commands' |