|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
From b06eb4603e2cdd45a78a2b74e19fafc2d784e906 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
Date: Wed, 29 Oct 2014 23:47:55 -0400
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
Subject: [PATCH] zsh-completion: update start/restart completions
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
Now zsh should behave the same for those two subcommands as bash.
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
(cherry picked from commit 81333ecf9d5497f8aa95f7fec23c67b869d5abf9)
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
shell-completion/zsh/_systemctl.in | 28 +++++++++++++++++++++-------
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
1 file changed, 21 insertions(+), 7 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
diff --git a/shell-completion/zsh/_systemctl.in b/shell-completion/zsh/_systemctl.in
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
index 44981fe85d..7eefe53aec 100644
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
--- a/shell-completion/zsh/_systemctl.in
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
+++ b/shell-completion/zsh/_systemctl.in
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
@@ -141,13 +141,29 @@ _filter_units_by_property() {
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
done
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
-_systemctl_all_units() { { __systemctl list-unit-files; __systemctl list-units --all; } | { while read -r a b; do echo -E - " $a"; done; } }
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
+_systemctl_all_units() { { __systemctl list-unit-files; __systemctl list-units --all; } | { while read -r a b; do [[ $a =~ @\. ]] || echo -E - " $a"; done; } }
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
_systemctl_get_template_names() { __systemctl list-unit-files | { while read -r a b; do [[ $a =~ @\. ]] && echo -E - " ${a%%@.*}@"; done; } }
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
_systemctl_active_units() {_sys_active_units=( $(__systemctl list-units | { while read -r a b; do echo -E - " $a"; done; }) )}
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
-_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; }) )}
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
-_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; }) )}
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
+_systemctl_startable_units(){
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
+ _sys_startable_units=(_filter_units_by_property ActiveState inactive $(
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
+ _filter_units_by_property CanStart yes $(
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
+ __systemctl $mode list-unit-files --state enabled,disabled,static | \
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
+ { while read -r a b; do [[ $a =~ @\. ]] || echo -E - " $a"; done; }
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
+ __systemctl $mode list-units --state inactive,failed | \
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
+ { while read -r a b; do echo -E - " $a"; done; } )))
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
+}
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
+_systemctl_restartable_units(){
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
+ _sys_restartable_units=(_filter_units_by_property CanStart yes $(
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
+ __systemctl $mode list-unit-files --state enabled,disabled,static | \
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
+ { while read -r a b; do [[ $a =~ @\. ]] || echo -E - " $a"; done; }
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
+ __systemctl $mode list-units | \
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
+ { while read -r a b; do echo -E - " $a"; done; } ))
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
+}
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
_systemctl_failed_units() {_sys_failed_units=( $(__systemctl list-units --failed | { while read -r a b; do echo -E - " $a"; done; }) )}
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
_systemctl_enabled_units() {_sys_enabled_units=( $(__systemctl list-unit-files | { while read -r a b; do [[ $b == "enabled" ]] && echo -E - " $a"; done; }) )}
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
_systemctl_disabled_units(){_sys_disabled_units=($(__systemctl list-unit-files | { while read -r a b; do [[ $b == "disabled" ]] && echo -E - " $a"; done; }) )}
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
@@ -194,8 +210,7 @@ done
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
(( $+functions[_systemctl_start] )) || _systemctl_start()
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
{
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
_systemctl_startable_units
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
- compadd "$@" - $( _filter_units_by_property CanStart yes \
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
- ${_sys_startable_units[*]} )
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
+ compadd "$@" - ${_sys_startable_units[*]} $(_systemctl_get_template_names)
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
# Completion functions for STOPPABLE_UNITS
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
@@ -231,8 +246,7 @@ for fun in restart reload-or-restart ; do
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
(( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
{
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
_systemctl_restartable_units
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
- compadd "$@" - $( _filter_units_by_property CanStart yes \
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
- ${_sys_restartable_units[*]} )
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
+ compadd "$@" - ${_sys_restartable_units[*]} $(_systemctl_get_template_names)
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
done
|
|
Zbigniew Jędrzejewski-Szmek |
ea1976 |
|