From 9ec0808370c7c1b020871d4a9a352166c46a6d92 Mon Sep 17 00:00:00 2001 From: Ronan Pigott Date: Wed, 19 Jul 2023 14:26:14 -0700 Subject: [PATCH] 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. --- shell-completion/zsh/_systemctl.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/shell-completion/zsh/_systemctl.in b/shell-completion/zsh/_systemctl.in index 85ea6d28f57..7ce7c4c0154 100644 --- a/shell-completion/zsh/_systemctl.in +++ b/shell-completion/zsh/_systemctl.in @@ -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)"}%% *} )} -- 2.47.3