]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
zsh: use glob matching for template names 28436/head
authorRonan Pigott <ronan@rjp.ie>
Wed, 19 Jul 2023 21:26:14 +0000 (14:26 -0700)
committerRonan Pigott <ronan@rjp.ie>
Wed, 19 Jul 2023 22:07:39 +0000 (15:07 -0700)
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

index 85ea6d28f57fe826915357e69d1d15a084ece7ca..7ce7c4c0154a89d87b0e0e444cd2042dd1d4aaa5 100644 (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)"}%% *} )}