]> git.ipfire.org Git - thirdparty/systemd.git/blob - shell-completion/zsh/_bootctl
Merge pull request #12818 from yuwata/network-issue-8726
[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 (( $+functions[_bootctl_commands] )) || _bootctl_commands()
28 {
29 local -a _bootctl_cmds
30 _bootctl_cmds=(
31 "status:Show status of installed systemd-boot and EFI variables"
32 "install:Install systemd-boot to the ESP and EFI variables"
33 "update:Update systemd-boot in the ESP and EFI variables"
34 "remove:Remove systemd-boot from the ESP and EFI variables"
35 "random-seed:Initialize random seed in ESP and EFI variables"
36 "is-installed:Test whether systemd-boot is installed in the ESP"
37 "set-default:Set the default boot loader entry"
38 "set-oneshot:Set the default boot loader entry only for the next boot"
39 )
40 if (( CURRENT == 1 )); then
41 _describe -t commands 'bootctl command' _bootctl_cmds || compadd "$@"
42 else
43 local curcontext="$curcontext"
44 cmd="${${_bootctl_cmds[(r)$words[1]:*]%%:*}}"
45 if (( $+functions[_bootctl_$cmd] )); then
46 _bootctl_$cmd
47 else
48 _message "no more options"
49 fi
50 fi
51 }
52
53 _arguments \
54 {-h,--help}'[Prints a short help text and exits.]' \
55 '--version[Prints a short version string and exits.]' \
56 '--esp-path=[Path to the EFI System Partition (ESP)]:path:_directories' \
57 '--boot-path=[Path to the $BOOT partition]:path:_directories' \
58 {-p,--print-esp-path}'[Print path to the EFI system partition]' \
59 {-x,--print-boot-path}'[Print path to the $BOOT partition]' \
60 '--no-variables[Do not touch EFI variables]' \
61 '--no-pager[Do not pipe output into a pager]' \
62 '*::bootctl command:_bootctl_commands'