mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-03-08 20:58:20 +03:00
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>
This commit is contained in:
parent
9b536b1af2
commit
4ed141166c
@ -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()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user