From d66d51f1011c1ccb5350c83ed7db949d5e66ad22 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Tue, 21 Jun 2016 12:43:50 +0200 Subject: [PATCH] systemctl completions: Add reset-failed completion Fixes #3153. --- share/completions/systemctl.fish | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/share/completions/systemctl.fish b/share/completions/systemctl.fish index 8f8116db7..28dd6b359 100644 --- a/share/completions/systemctl.fish +++ b/share/completions/systemctl.fish @@ -23,6 +23,15 @@ function __fish_systemd_properties end end +function __fish_systemctl_failed + if __fish_contains_opt user + # Without arguments, no "--type=" will be passed + systemctl --user list-units --state=failed --no-legend --type=$argv ^/dev/null | cut -f 1 -d ' ' + else + systemctl list-units --state=failed --no-legend --type=$argv ^/dev/null | cut -f 1 -d ' ' + end +end + complete -f -e -c systemctl # All systemctl commands complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a "$commands" @@ -42,6 +51,9 @@ for command in start stop restart try-restart reload-or-restart reload-or-try-re end end +# Handle reset-failed specially because it doesn't apply to unit-files (only units that have been tried can have failed) and a second "--state=" argument doesn't override the earlier one. +complete -f -c systemctl -n "__fish_seen_subcommand_from reset-failed" -a "(__fish_systemctl_failed)" + # Enable/Disable: Only show units with matching state for t in services sockets timers service_paths complete -f -c systemctl -n "__fish_seen_subcommand_from enable" -a "(eval __fish_systemctl_$t --state=disabled)"