zsh: use glob matching for template names

Template names can be learned from the filesystem, so there isn't a need
to parse the output of systemctl list-unit-files in this case. This
should accelerate the completion of some verbs like enable.
This commit is contained in:
Ronan Pigott 2023-07-19 14:26:14 -07:00
parent ae6fb82cd9
commit 9ec0808370

View file

@ -200,7 +200,10 @@ __systemctl()
)"}:#*@.*}%%[[:space:]]*} }
(( $+functions[_systemctl_get_template_names] )) ||
_systemctl_get_template_names() { echo -E - ${^${(M)${(f)"$(__systemctl list-unit-files)"}##*@.[^[:space:]]##}%%@.*}\@ }
_systemctl_get_template_names() {
local pathkind=systemd-search-${_sys_service_mgr##*--}-unit
print -r - ${(s-:-)^$(_call_program $pathkind systemd-path $pathkind)}/*@.(${(~j.|.)$(__systemctl --type=help)})(N:t:r)
}
(( $+functions[_systemctl_active_units] )) ||
_systemctl_active_units() {_sys_active_units=( ${${(f)"$(__systemctl list-units)"}%% *} )}