From 00b20098515d1ab663586947553144f2c8dd6398 Mon Sep 17 00:00:00 2001 From: Roland Fredenhagen Date: Mon, 10 Feb 2025 00:03:14 +0100 Subject: [PATCH] Complete entries for bootctl Uses `jq` to parse and doesn't add these extra completions if not available. (cherry picked from commit d862e7bf26b7e9c1558174c591287ed98431a690) --- share/completions/bootctl.fish | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/share/completions/bootctl.fish b/share/completions/bootctl.fish index 73b67449a..fc587111e 100644 --- a/share/completions/bootctl.fish +++ b/share/completions/bootctl.fish @@ -1,5 +1,14 @@ set -l commands status install update remove is-installed random-seed systemd-efi-options reboot-to-firmware list set-default set-oneshot set-timeout set-timeout-oneshot +# Execute `bootctl list` and return entries +function __bootctl_entries + if not type -q jq + return 1 + end + + bootctl list --json short | jq '.[] | "\(.id)\t\(.showTitle)"' --raw-output +end + complete -c bootctl -f complete -c bootctl -n "not __fish_seen_subcommand_from $commands" -a status -d 'Show status of EFI variables' complete -c bootctl -n "not __fish_seen_subcommand_from $commands" -a install -d 'Install systemd-boot' @@ -13,6 +22,7 @@ complete -c bootctl -n "__fish_seen_subcommand_from reboot-to-firmware" -a 'true complete -c bootctl -n "not __fish_seen_subcommand_from $commands" -a list -d 'List boot loader entries' complete -c bootctl -n "not __fish_seen_subcommand_from $commands" -a set-default -d 'Set default boot loader entry' complete -c bootctl -n "not __fish_seen_subcommand_from $commands" -a set-oneshot -d 'Set default boot loader entry (Once)' +complete -c bootctl -n "__fish_seen_subcommand_from set-default set-oneshot" -x -a '(__bootctl_entries)' complete -c bootctl -n "not __fish_seen_subcommand_from $commands" -a set-timeout -d 'Set default boot loader timeout' complete -c bootctl -n "not __fish_seen_subcommand_from $commands" -a set-timeout-oneshot -d 'Set default boot loader timeout (Once)'