summaryrefslogtreecommitdiffstats
path: root/shell-completion/zsh/_systemctl.in
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2020-01-07 21:17:26 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-01-08 09:43:01 +0100
commit356873ddec61ed814aec3cf984cb9a0533984f9c (patch)
tree849cbc140cea39cdc2f4e846a6cc2c32309f0435 /shell-completion/zsh/_systemctl.in
parentMerge pull request #14423 from danielshahaf/zsh-add-missing-completions (diff)
downloadsystemd-356873ddec61ed814aec3cf984cb9a0533984f9c.tar.xz
systemd-356873ddec61ed814aec3cf984cb9a0533984f9c.zip
zsh: Complete systemctl subcommands in separate tags
Fixes #14422
Diffstat (limited to '')
-rw-r--r--shell-completion/zsh/_systemctl.in28
1 files changed, 17 insertions, 11 deletions
diff --git a/shell-completion/zsh/_systemctl.in b/shell-completion/zsh/_systemctl.in
index 18663fca2e..66bf03d058 100644
--- a/shell-completion/zsh/_systemctl.in
+++ b/shell-completion/zsh/_systemctl.in
@@ -3,6 +3,8 @@
(( $+functions[_systemctl_commands] )) || _systemctl_commands()
{
+ local expl i
+
local -a unit_commands=(
# Unit Commands
"list-sockets:List sockets"
@@ -97,20 +99,24 @@
"suspend-then-hibernate:Suspend the system for a period of time, and then hibernate it"
)
- local -a _systemctl_cmds=(
- "${unit_commands[@]}"
- "${machine_commands[@]}"
- "${unit_file_commands[@]}"
- "${job_commands[@]}"
- "${environment_commands[@]}"
- "${manager_state_commands[@]}"
- "${system_commands[@]}"
- )
+ local -a groups=( unit machine unit_file job environment manager_state system )
+ local -a _systemctl_cmds
+ for i in $groups; do
+ _systemctl_cmds+=( "${(@P)${:-"${i}_commands"}}" )
+ done
if (( CURRENT == 1 )); then
- _describe -t commands 'systemctl command' _systemctl_cmds || compadd "$@"
+ _tags ${^groups//_/-}-commands
+ while _tags; do
+ for i in $groups; do
+ if _requested ${i//_/-}-commands; then
+ _describe -t ${i//_/-}-commands "${i//_/ } command" ${i}_commands \
+ && ret=0
+ fi
+ done
+ done
else
- local curcontext="$curcontext" expl
+ local curcontext="$curcontext"
cmd="${${_systemctl_cmds[(r)$words[1]:*]%%:*}}"
# Deal with any aliases