diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-10-29 23:06:58 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-10-30 00:18:35 -0400 |
commit | ad894f24df73d6b5f596ff610e7ce98b4e45827f (patch) | |
tree | 39c3965568465da598bb4fb931c9aa6628f7aacd | |
parent | f971bf69e3e7d188e1cd7fa77fc7cd990e1b904e (diff) |
bash-completion: use improved filtering to make things faster
(cherry picked from commit 372b221166eb586c4f767969f442ed940e21f353)
-rw-r--r-- | shell-completion/bash/systemctl.in | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/shell-completion/bash/systemctl.in b/shell-completion/bash/systemctl.in index 8ef4070f5..9d9ff22e3 100644 --- a/shell-completion/bash/systemctl.in +++ b/shell-completion/bash/systemctl.in @@ -60,14 +60,20 @@ __get_active_units () { __systemctl $1 list-units \ | { while read -r a b; do echo " $a"; done; }; } __get_startable_units () { # find startable inactive units - __filter_units_by_property $mode LoadState loaded $( - __filter_units_by_property $mode ActiveState inactive $( - __filter_units_by_property $mode CanStart yes $( __get_all_units ))) + __filter_units_by_property $mode ActiveState inactive $( + __filter_units_by_property $mode CanStart yes $( + __systemctl $mode list-unit-files --state enabled,disabled,static | \ + { while read -r a b; do [[ $a =~ @\. ]] || echo " $a"; done; } + __systemctl $mode list-units --state inactive,failed | \ + { while read -r a b; do echo " $a"; done; } )) } __get_restartable_units () { # filter out masked and not-found - __filter_units_by_property $mode LoadState loaded $( - __filter_units_by_property $mode CanStart yes $( __get_all_units )) + __filter_units_by_property $mode CanStart yes $( + __systemctl $mode list-unit-files --state enabled,disabled,static | \ + { while read -r a b; do [[ $a =~ @\. ]] || echo " $a"; done; } + __systemctl $mode list-units | \ + { while read -r a b; do echo " $a"; done; } ) } __get_failed_units () { __systemctl $1 list-units \ | { while read -r a b c d; do [[ $c == "failed" ]] && echo " $a"; done; }; } |