]> git.ipfire.org Git - thirdparty/systemd.git/blob - shell-completion/zsh/_bootctl
Merge pull request #15990 from jwrdegoede/hwdb-accel-quirks
[thirdparty/systemd.git] / shell-completion / zsh / _bootctl
1 #compdef bootctl -*- shell-script -*-
2 # SPDX-License-Identifier: LGPL-2.1+
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 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_reboot-to-firmware() {
28 local -a _completions
29 _completions=( yes no )
30 typeset -U _completions
31 _describe 'possible values' _completions
32 }
33
34 (( $+functions[_bootctl_commands] )) || _bootctl_commands()
35 {
36 local -a _bootctl_cmds
37 _bootctl_cmds=(
38 "status:Show status of installed systemd-boot and EFI variables"
39 "install:Install systemd-boot to the ESP and EFI variables"
40 "update:Update systemd-boot in the ESP and EFI variables"
41 "remove:Remove systemd-boot from the ESP and EFI variables"
42 "is-installed:Test whether systemd-boot is installed in the ESP"
43 "random-seed:Initialize random seed in ESP and EFI variables"
44 "systemd-efi-options:Query or set system options string in EFI variable"
45 "reboot-to-firmware:Query or set reboot-to-firmware EFI flag"
46 "list:List boot loader entries"
47 "set-default:Set the default boot loader entry"
48 "set-oneshot:Set the default boot loader entry only for the next boot"
49 )
50 if (( CURRENT == 1 )); then
51 _describe -t commands 'bootctl command' _bootctl_cmds || compadd "$@"
52 else
53 local curcontext="$curcontext"
54 cmd="${${_bootctl_cmds[(r)$words[1]:*]%%:*}}"
55 if (( $+functions[_bootctl_$cmd] )); then
56 _bootctl_$cmd
57 else
58 _message "no more options"
59 fi
60 fi
61 }
62
63 _arguments \
64 {-h,--help}'[Prints a short help text and exits.]' \
65 '--version[Prints a short version string and exits.]' \
66 '--esp-path=[Path to the EFI System Partition (ESP)]:path:_directories' \
67 '--boot-path=[Path to the $BOOT partition]:path:_directories' \
68 {-p,--print-esp-path}'[Print path to the EFI system partition]' \
69 {-x,--print-boot-path}'[Print path to the $BOOT partition]' \
70 '--no-variables[Do not touch EFI variables]' \
71 '--no-pager[Do not pipe output into a pager]' \
72 '--graceful[Do not fail when locating ESP or writing fails]' \
73 '*::bootctl command:_bootctl_commands'