diff options
author | Emil Velikov <emil.velikov@collabora.com> | 2018-06-11 12:53:08 +0200 |
---|---|---|
committer | Emil Velikov <emil.l.velikov@gmail.com> | 2018-06-11 20:02:36 +0200 |
commit | 4ed141166c8b3a633ca7b5e15828071dce63eab0 (patch) | |
tree | f3cc20f22f45cc83186a2ebacd3fb443ceb28736 | |
parent | shell-completion: systemctl: do not list template units in {re,}start (diff) | |
download | systemd-4ed141166c8b3a633ca7b5e15828071dce63eab0.tar.xz systemd-4ed141166c8b3a633ca7b5e15828071dce63eab0.zip |
zsh-completion: systemctl: list template units only as needed
Currently the completion adds template units for commands such as
is-active, is-failed, is-enabled, status, show and others.
At the same time systemctl barfs at us, since an instanced template unit
is needed. Follow the example list from bash-completion as to which
commands should not list template units.
Note: The above is observed regardless of DefaultInstance.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
-rw-r--r-- | shell-completion/zsh/_systemctl.in | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/shell-completion/zsh/_systemctl.in b/shell-completion/zsh/_systemctl.in index 173e815a19..9f576ed77d 100644 --- a/shell-completion/zsh/_systemctl.in +++ b/shell-completion/zsh/_systemctl.in @@ -135,6 +135,11 @@ _filter_units_by_property() { echo -E - "${(@g:o:)${(k@)props[(Re)$property=$value]}#Id=}" } +_systemctl_get_non_template_names() { echo -E - ${^${(R)${(f)"$( + __systemctl $mode list-unit-files "$PREFIX*" + __systemctl $mode list-units --all "$PREFIX*" + )"}:#*@.*}%%[[:space:]]*} } + _systemctl_get_template_names() { echo -E - ${^${(M)${(f)"$(__systemctl list-unit-files "$PREFIX*" )"}##*@.[^[:space:]]##}%%@.*}\@ } @@ -161,7 +166,7 @@ _systemctl_unit_state() { typeset -gA _sys_unit_state; _sys_unit_state=( $(__sys local fun # Completion functions for ALL_UNITS -for fun in is-active is-failed is-enabled status show cat mask preset help list-dependencies edit revert add-wants add-requires ; do +for fun in cat mask ; do (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() { _systemctl_really_all_units @@ -170,6 +175,15 @@ for fun in is-active is-failed is-enabled status show cat mask preset help list- } done +# Completion functions for NONTEMPLATE_UNITS +for fun in is-active is-failed is-enabled status show preset help list-dependencies edit revert add-wants add-requires ; do + (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() + { + _wanted systemd-units expl unit \ + compadd "$@" - $(_systemctl_get_non_template_names) + } +done + # Completion functions for ENABLED_UNITS (( $+functions[_systemctl_disable] )) || _systemctl_disable() { |