summaryrefslogtreecommitdiff
path: root/shell-completion/zsh/_systemctl.in
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-10-29 23:47:55 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-10-29 23:48:10 -0400
commit81333ecf9d5497f8aa95f7fec23c67b869d5abf9 (patch)
treea133ae1cf7b1c310f6380a9d713547d73afad736 /shell-completion/zsh/_systemctl.in
parent372b221166eb586c4f767969f442ed940e21f353 (diff)
zsh-completion: update start/restart completions
Now zsh should behave the same for those two subcommands as bash.
Diffstat (limited to 'shell-completion/zsh/_systemctl.in')
-rw-r--r--shell-completion/zsh/_systemctl.in28
1 files changed, 21 insertions, 7 deletions
diff --git a/shell-completion/zsh/_systemctl.in b/shell-completion/zsh/_systemctl.in
index 44981fe85d..7eefe53aec 100644
--- a/shell-completion/zsh/_systemctl.in
+++ b/shell-completion/zsh/_systemctl.in
@@ -141,13 +141,29 @@ _filter_units_by_property() {
done
}
-_systemctl_all_units() { { __systemctl list-unit-files; __systemctl list-units --all; } | { while read -r a b; do echo -E - " $a"; done; } }
+_systemctl_all_units() { { __systemctl list-unit-files; __systemctl list-units --all; } | { while read -r a b; do [[ $a =~ @\. ]] || echo -E - " $a"; done; } }
_systemctl_get_template_names() { __systemctl list-unit-files | { while read -r a b; do [[ $a =~ @\. ]] && echo -E - " ${a%%@.*}@"; done; } }
_systemctl_active_units() {_sys_active_units=( $(__systemctl list-units | { while read -r a b; do echo -E - " $a"; done; }) )}
-_systemctl_startable_units(){_sys_startable_units=($(__systemctl list-units --state inactive,failed -- $(_systemctl_all_units) | { while read -r a b c d; do [[ $b == "loaded" ]] && echo -E - " $a"; done; }) )}
-_systemctl_restartable_units(){_sys_restartable_units=($(__systemctl list-units --state inactive,failed,active -- $(_systemctl_all_units) | { while read -r a b c d; do [[ $b == "loaded" ]] && echo -E - " $a"; done; }) )}
+
+_systemctl_startable_units(){
+ _sys_startable_units=(_filter_units_by_property ActiveState inactive $(
+ _filter_units_by_property CanStart yes $(
+ __systemctl $mode list-unit-files --state enabled,disabled,static | \
+ { while read -r a b; do [[ $a =~ @\. ]] || echo -E - " $a"; done; }
+ __systemctl $mode list-units --state inactive,failed | \
+ { while read -r a b; do echo -E - " $a"; done; } )))
+}
+
+_systemctl_restartable_units(){
+ _sys_restartable_units=(_filter_units_by_property CanStart yes $(
+ __systemctl $mode list-unit-files --state enabled,disabled,static | \
+ { while read -r a b; do [[ $a =~ @\. ]] || echo -E - " $a"; done; }
+ __systemctl $mode list-units | \
+ { while read -r a b; do echo -E - " $a"; done; } ))
+}
+
_systemctl_failed_units() {_sys_failed_units=( $(__systemctl list-units --failed | { while read -r a b; do echo -E - " $a"; done; }) )}
_systemctl_enabled_units() {_sys_enabled_units=( $(__systemctl list-unit-files | { while read -r a b; do [[ $b == "enabled" ]] && echo -E - " $a"; done; }) )}
_systemctl_disabled_units(){_sys_disabled_units=($(__systemctl list-unit-files | { while read -r a b; do [[ $b == "disabled" ]] && echo -E - " $a"; done; }) )}
@@ -194,8 +210,7 @@ done
(( $+functions[_systemctl_start] )) || _systemctl_start()
{
_systemctl_startable_units
- compadd "$@" - $( _filter_units_by_property CanStart yes \
- ${_sys_startable_units[*]} )
+ compadd "$@" - ${_sys_startable_units[*]} $(_systemctl_get_template_names)
}
# Completion functions for STOPPABLE_UNITS
@@ -231,8 +246,7 @@ for fun in restart reload-or-restart ; do
(( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
{
_systemctl_restartable_units
- compadd "$@" - $( _filter_units_by_property CanStart yes \
- ${_sys_restartable_units[*]} )
+ compadd "$@" - ${_sys_restartable_units[*]} $(_systemctl_get_template_names)
}
done