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)"