completions/systemctl: Add some missing commands

Fixes #9804

(cherry picked from commit aac30367bf)
This commit is contained in:
Fabian Boehm 2023-05-21 10:02:26 +02:00
parent 40b0a744e9
commit 513e29f7b6
2 changed files with 12 additions and 3 deletions

View file

@ -4,7 +4,8 @@ set -l commands list-units list-sockets start stop reload restart try-restart re
reset-failed list-unit-files enable disable is-enabled reenable preset mask unmask link load list-jobs cancel dump \
list-dependencies snapshot delete daemon-reload daemon-reexec show-environment set-environment unset-environment \
default rescue emergency halt poweroff reboot kexec exit suspend hibernate hybrid-sleep switch-root list-timers \
set-property import-environment
set-property import-environment get-default list-automounts is-system-running try-reload-or-restart freeze \
thaw mount-image bind clean
if test $systemd_version -gt 208 2>/dev/null
set commands $commands cat
if test $systemd_version -gt 217 2>/dev/null
@ -30,12 +31,20 @@ complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a "$com
complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a start -d 'Start one or more units'
complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a stop -d 'Stop one or more units'
complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a restart -d 'Restart one or more units'
complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a reload-or-restart -d 'Reload units if supported or restart them'
complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a try-reload-or-restart -d 'Reload units if supported or restart them, if running'
complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a status -d 'Runtime status about one or more units'
complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a enable -d 'Enable one or more units'
complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a disable -d 'Disable one or more units'
complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a isolate -d 'Start a unit and dependencies and disable all others'
complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a set-default -d 'Set the default target to boot into'
complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a get-default -d 'Show the default target to boot into'
complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a set-property -d 'Sets one or more properties of a unit'
complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a list-automounts -d 'List automount units'
complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a is-system-running -d 'Return if system is running/starting/degraded'
complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a freeze -d 'Freeze units with the cgroup freezer'
complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a thaw -d 'Unfreeze frozen units'
complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a clean -d 'Remove config/state/logs for the given units'
# Command completion done via argparse.
complete -c systemctl -a '(__fish_systemctl)' -f

View file

@ -30,7 +30,7 @@ function __fish_systemctl --description 'Call systemctl with some options from t
# These are the normal commands, so just complete all units.
# For "restart" et al, also complete non-running ones, since it can be used regardless of state.
case reenable status reload {try-,}{reload-or-,}restart is-{active,enabled,failed} show cat \
help reset-failed list-dependencies list-units revert add-{wants,requires} edit
help reset-failed list-dependencies list-units revert add-{wants,requires} edit clean thaw
case enable
# This will only work for "list-unit-files", but won't print an error for "list-units".
set -q _flag_state; or set _flag_state disabled
@ -43,7 +43,7 @@ function __fish_systemctl --description 'Call systemctl with some options from t
set -q _flag_state; or set _flag_state loaded
case unmask
set -q _flag_state; or set _flag_state masked
case stop kill
case stop kill freeze
# TODO: Is "kill" useful on other unit types?
# Running as the catch-all, "mounted" for .mount units, "active" for .target.
set -q _flag_state; or set _flag_state running,mounted,active