diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-04-05 11:39:14 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-04-12 08:34:44 +0200 |
commit | 843cfcb15c1f55c37cc1baae3e12210287c1f5c6 (patch) | |
tree | 8435abc7e3d2f26a04fbc98336bf971aa2d4f9aa /shell-completion/zsh | |
parent | scripts: use 4 space indentation (diff) | |
download | systemd-843cfcb15c1f55c37cc1baae3e12210287c1f5c6.tar.xz systemd-843cfcb15c1f55c37cc1baae3e12210287c1f5c6.zip |
shell-completion: use 4 space indentation too
The same as in other places, indentation levels were all over the place.
Diffstat (limited to 'shell-completion/zsh')
-rw-r--r-- | shell-completion/zsh/_coredumpctl | 8 | ||||
-rw-r--r-- | shell-completion/zsh/_kernel-install | 2 | ||||
-rw-r--r-- | shell-completion/zsh/_loginctl | 196 | ||||
-rw-r--r-- | shell-completion/zsh/_machinectl | 176 | ||||
-rw-r--r-- | shell-completion/zsh/_networkctl | 38 | ||||
-rw-r--r-- | shell-completion/zsh/_sd_hosts_or_user_at_host | 4 | ||||
-rw-r--r-- | shell-completion/zsh/_sd_machines | 8 | ||||
-rw-r--r-- | shell-completion/zsh/_systemctl.in | 468 | ||||
-rw-r--r-- | shell-completion/zsh/_systemd | 18 | ||||
-rw-r--r-- | shell-completion/zsh/_systemd-analyze | 98 | ||||
-rw-r--r-- | shell-completion/zsh/_systemd-resolve | 41 | ||||
-rw-r--r-- | shell-completion/zsh/_systemd-run | 68 | ||||
-rw-r--r-- | shell-completion/zsh/_udevadm | 1 |
13 files changed, 560 insertions, 566 deletions
diff --git a/shell-completion/zsh/_coredumpctl b/shell-completion/zsh/_coredumpctl index e446ad349c..74491626aa 100644 --- a/shell-completion/zsh/_coredumpctl +++ b/shell-completion/zsh/_coredumpctl @@ -5,10 +5,10 @@ _coredumpctl_commands(){ local -a _coredumpctl_cmds _coredumpctl_cmds=( - 'list:List available coredumps' - 'info:Show detailed information about one or more coredumps' - 'dump:Print coredump to stdout' - 'debug:Start debugger (gdb) on a coredump' + 'list:List available coredumps' + 'info:Show detailed information about one or more coredumps' + 'dump:Print coredump to stdout' + 'debug:Start debugger (gdb) on a coredump' ) if (( CURRENT == 1 )); then _describe -t commands 'coredumpctl command' _coredumpctl_cmds diff --git a/shell-completion/zsh/_kernel-install b/shell-completion/zsh/_kernel-install index 14793c2f3f..5be5c4c3f2 100644 --- a/shell-completion/zsh/_kernel-install +++ b/shell-completion/zsh/_kernel-install @@ -25,5 +25,3 @@ _arguments \ '1::add or remove:(add remove)' \ '2::kernel versions:_kernel-install_kernels' \ '3::kernel images:_kernel-install_images' - -#vim: set ft=zsh sw=4 ts=4 et diff --git a/shell-completion/zsh/_loginctl b/shell-completion/zsh/_loginctl index 44d6d08c98..c421a9b6c4 100644 --- a/shell-completion/zsh/_loginctl +++ b/shell-completion/zsh/_loginctl @@ -3,158 +3,158 @@ (( $+functions[_loginctl_all_sessions] )) || _loginctl_all_sessions() { - local session description - loginctl --no-legend list-sessions | while read -r session description; do - _sys_all_sessions+=( "$session" ) - _sys_all_sessions_descr+=( "${session}:$description" ) - done + local session description + loginctl --no-legend list-sessions | while read -r session description; do + _sys_all_sessions+=( "$session" ) + _sys_all_sessions_descr+=( "${session}:$description" ) + done } (( $+functions[_loginctl_all_users] )) || _loginctl_all_users() { - local uid description - loginctl --no-legend list-users | while read -r uid description; do - _sys_all_users+=( "$uid" ) - _sys_all_users_descr+=( "${uid}:$description" ) - done + local uid description + loginctl --no-legend list-users | while read -r uid description; do + _sys_all_users+=( "$uid" ) + _sys_all_users_descr+=( "${uid}:$description" ) + done } (( $+functions[_loginctl_all_seats] )) || _loginctl_all_seats() { - local seat description - loginctl --no-legend list-seats | while read -r seat description; do - _sys_all_seats+=( "$seat" ) - _sys_all_seats_descr+=( "${seat}:$description" ) - done + local seat description + loginctl --no-legend list-seats | while read -r seat description; do + _sys_all_seats+=( "$seat" ) + _sys_all_seats_descr+=( "${seat}:$description" ) + done } local fun # Completion functions for SESSIONS for fun in session-status show-session activate lock-session unlock-session terminate-session kill-session ; do - (( $+functions[_loginctl_$fun] )) || _loginctl_$fun() - { + (( $+functions[_loginctl_$fun] )) || +_loginctl_$fun() { local -a _sys_all_sessions{,_descr} _loginctl_all_sessions for _ignore in $words[2,-1]; do - _sys_all_sessions[(i)$_ignore]=() - _sys_all_sessions_descr[(i)$_ignore:*]=() + _sys_all_sessions[(i)$_ignore]=() + _sys_all_sessions_descr[(i)$_ignore:*]=() done if zstyle -T ":completion:${curcontext}:systemd-sessions" verbose; then - _describe -t systemd-sessions session _sys_all_sessions_descr _sys_all_sessions "$@" + _describe -t systemd-sessions session _sys_all_sessions_descr _sys_all_sessions "$@" else - local expl - _wanted systemd-sessions expl session compadd "$@" -a _sys_all_sessions + local expl + _wanted systemd-sessions expl session compadd "$@" -a _sys_all_sessions fi - } +} done # Completion functions for USERS for fun in user-status show-user enable-linger disable-linger terminate-user kill-user ; do - (( $+functions[_loginctl_$fun] )) || _loginctl_$fun() - { + (( $+functions[_loginctl_$fun] )) || +_loginctl_$fun() { local -a _sys_all_users{,_descr} zstyle -a ":completion:${curcontext}:users" users _sys_all_users if ! (( $#_sys_all_users )); then - _loginctl_all_users + _loginctl_all_users fi for _ignore in $words[2,-1]; do - _sys_all_users[(i)$_ignore]=() - _sys_all_users_descr[(i)$_ignore:*]=() + _sys_all_users[(i)$_ignore]=() + _sys_all_users_descr[(i)$_ignore:*]=() done # using the common tag `users' here, not rolling our own `systemd-users' tag if zstyle -T ":completion:${curcontext}:users" verbose; then - _describe -t users user ${_sys_all_users_descr:+_sys_all_users_descr} _sys_all_users "$@" + _describe -t users user ${_sys_all_users_descr:+_sys_all_users_descr} _sys_all_users "$@" else - local expl - _wanted users expl user compadd "$@" -a _sys_all_users + local expl + _wanted users expl user compadd "$@" -a _sys_all_users fi - } +} done # Completion functions for SEATS -(( $+functions[_loginctl_seats] )) || _loginctl_seats() -{ - local -a _sys_all_seats{,_descr} - - _loginctl_all_seats - for _ignore in $words[2,-1]; do - _sys_all_seats[(i)$_ignore]=() - _sys_all_seats_descr[(i)$_ignore:*]=() - done - - if zstyle -T ":completion:${curcontext}:systemd-seats" verbose; then - _describe -t systemd-seats seat _sys_all_seats_descr _sys_all_seats "$@" - else - local expl - _wanted systemd-seats expl seat compadd "$@" -a _sys_all_seats - fi +(( $+functions[_loginctl_seats] )) || +_loginctl_seats() { + local -a _sys_all_seats{,_descr} + + _loginctl_all_seats + for _ignore in $words[2,-1]; do + _sys_all_seats[(i)$_ignore]=() + _sys_all_seats_descr[(i)$_ignore:*]=() + done + + if zstyle -T ":completion:${curcontext}:systemd-seats" verbose; then + _describe -t systemd-seats seat _sys_all_seats_descr _sys_all_seats "$@" + else + local expl + _wanted systemd-seats expl seat compadd "$@" -a _sys_all_seats + fi } for fun in seat-status show-seat terminate-seat ; do - (( $+functions[_loginctl_$fun] )) || _loginctl_$fun() - { _loginctl_seats } + (( $+functions[_loginctl_$fun] )) || +_loginctl_$fun() { _loginctl_seats } done # Completion functions for ATTACH -(( $+functions[_loginctl_attach] )) || _loginctl_attach() -{ - _arguments -w -C -S -s \ - ':seat:_loginctl_seats' \ - '*:device:_files' +(( $+functions[_loginctl_attach] )) || +_loginctl_attach() { + _arguments -w -C -S -s \ + ':seat:_loginctl_seats' \ + '*:device:_files' } # no loginctl completion for: # [STANDALONE]='list-sessions list-users list-seats flush-devices' -(( $+functions[_loginctl_commands] )) || _loginctl_commands() -{ - local -a _loginctl_cmds - _loginctl_cmds=( - "list-sessions:List sessions" - "session-status:Show session status" - "show-session:Show properties of one or more sessions" - "activate:Activate a session" - "lock-session:Screen lock one or more sessions" - "unlock-session:Screen unlock one or more sessions" - "lock-sessions:Screen lock all current sessions" - "unlock-sessions:Screen unlock all current sessions" - "terminate-session:Terminate one or more sessions" - "kill-session:Send signal to processes of a session" - "list-users:List users" - "user-status:Show user status" - "show-user:Show properties of one or more users" - "enable-linger:Enable linger state of one or more users" - "disable-linger:Disable linger state of one or more users" - "terminate-user:Terminate all sessions of one or more users" - "kill-user:Send signal to processes of a user" - "list-seats:List seats" - "seat-status:Show seat status" - "show-seat:Show properties of one or more seats" - "attach:Attach one or more devices to a seat" - "flush-devices:Flush all device associations" - "terminate-seat:Terminate all sessions on one or more seats" - ) - - if (( CURRENT == 1 )); then - _describe -t commands 'loginctl command' _loginctl_cmds || compadd "$@" - else - local curcontext="$curcontext" _ignore - - cmd="${${_loginctl_cmds[(r)$words[1]:*]%%:*}}" - - if (( $#cmd )); then - curcontext="${curcontext%:*:*}:loginctl-${cmd}:" - - _call_function ret _loginctl_$cmd || _message 'no more arguments' +(( $+functions[_loginctl_commands] )) || +_loginctl_commands() { + local -a _loginctl_cmds + _loginctl_cmds=( + "list-sessions:List sessions" + "session-status:Show session status" + "show-session:Show properties of one or more sessions" + "activate:Activate a session" + "lock-session:Screen lock one or more sessions" + "unlock-session:Screen unlock one or more sessions" + "lock-sessions:Screen lock all current sessions" + "unlock-sessions:Screen unlock all current sessions" + "terminate-session:Terminate one or more sessions" + "kill-session:Send signal to processes of a session" + "list-users:List users" + "user-status:Show user status" + "show-user:Show properties of one or more users" + "enable-linger:Enable linger state of one or more users" + "disable-linger:Disable linger state of one or more users" + "terminate-user:Terminate all sessions of one or more users" + "kill-user:Send signal to processes of a user" + "list-seats:List seats" + "seat-status:Show seat status" + "show-seat:Show properties of one or more seats" + "attach:Attach one or more devices to a seat" + "flush-devices:Flush all device associations" + "terminate-seat:Terminate all sessions on one or more seats" + ) + + if (( CURRENT == 1 )); then + _describe -t commands 'loginctl command' _loginctl_cmds || compadd "$@" else - _message "unknown loginctl command: $words[1]" + local curcontext="$curcontext" _ignore + + cmd="${${_loginctl_cmds[(r)$words[1]:*]%%:*}}" + + if (( $#cmd )); then + curcontext="${curcontext%:*:*}:loginctl-${cmd}:" + + _call_function ret _loginctl_$cmd || _message 'no more arguments' + else + _message "unknown loginctl command: $words[1]" + fi + return ret fi - return ret - fi } diff --git a/shell-completion/zsh/_machinectl b/shell-completion/zsh/_machinectl index 4561e4db75..1590b9f1b9 100644 --- a/shell-completion/zsh/_machinectl +++ b/shell-completion/zsh/_machinectl @@ -2,104 +2,104 @@ # SPDX-License-Identifier: LGPL-2.1+ (( $+functions[__machinectl_get_machines] )) || -__machinectl_get_machines () { - machinectl --no-legend list-images | {while read -r a b; do echo $a; done;} -} + __machinectl_get_machines () { + machinectl --no-legend list-images | {while read -r a b; do echo $a; done;} + } (( $+functions[_machinectl_machines] )) || -_machinectl_machines() { - local -a _machines - _machines=("${(fo)$(__machinectl_get_machines)}") - typeset -U _machines - if [[ -n "$_machines" ]]; then - _describe 'machines' _machines - else - _message 'no machines' - fi -} + _machinectl_machines() { + local -a _machines + _machines=("${(fo)$(__machinectl_get_machines)}") + typeset -U _machines + if [[ -n "$_machines" ]]; then + _describe 'machines' _machines + else + _message 'no machines' + fi + } (( $+functions[_machinectl_commands] )) || _machinectl_commands() { - local -a _machinectl_cmds - _machinectl_cmds=( - "list:List currently running VMs/containers" - "status:Show VM/container status" - "show:Show properties of one or more VMs/containers" - "start:Start container as a service" - "stop:Stop container (equal to poweroff)" - "login:Get a login prompt on a VM/container" - "enable:Enable automatic container start at boot" - "disable:Disable automatic container start at boot" - "poweroff:Power off one or more VMs/containers" - "reboot:Reboot one or more VMs/containers" - "terminate:Terminate one or more VMs/containers" - "kill:Send signal to process or a VM/container" - "copy-to:Copy files from the host to a container" - "copy-from:Copy files from a container to the host" - "bind:Bind mount a path from the host into a container" + local -a _machinectl_cmds + _machinectl_cmds=( + "list:List currently running VMs/containers" + "status:Show VM/container status" + "show:Show properties of one or more VMs/containers" + "start:Start container as a service" + "stop:Stop container (equal to poweroff)" + "login:Get a login prompt on a VM/container" + "enable:Enable automatic container start at boot" + "disable:Disable automatic container start at boot" + "poweroff:Power off one or more VMs/containers" + "reboot:Reboot one or more VMs/containers" + "terminate:Terminate one or more VMs/containers" + "kill:Send signal to process or a VM/container" + "copy-to:Copy files from the host to a container" + "copy-from:Copy files from a container to the host" + "bind:Bind mount a path from the host into a container" - "list-images:Show available container and VM images" - "image-status:Show image details" - "show-image:Show properties of image" - "clone:Clone an image" - "rename:Rename an image" - "read-only:Mark or unmark image read-only" - "remove:Remove an image" + "list-images:Show available container and VM images" + "image-status:Show image details" + "show-image:Show properties of image" + "clone:Clone an image" + "rename:Rename an image" + "read-only:Mark or unmark image read-only" + "remove:Remove an image" - "pull-tar:Download a TAR container image" - "pull-raw:Download a RAW container or VM image" - "list-transfers:Show list of downloads in progress" - "cancel-transfer:Cancel a download" - ) + "pull-tar:Download a TAR container image" + "pull-raw:Download a RAW container or VM image" + "list-transfers:Show list of downloads in progress" + "cancel-transfer:Cancel a download" + ) - if (( CURRENT == 1 )); then - _describe -t commands 'machinectl command' _machinectl_cmds || compadd "$@" - else - local curcontext="$curcontext" - cmd="${${_machinectl_cmds[(r)$words[1]:*]%%:*}}" - if (( $#cmd )); then - if (( CURRENT == 2 )); then - case $cmd in - list*|cancel-transfer|pull-tar|pull-raw) - msg="no options" ;; - clone) - _machinectl_machines ;; - start) - _machinectl_machines ;; - *) - _sd_machines - esac - else - case $cmd in - copy-to|copy-from|bind) - _files ;; - *) msg="no options" - esac - fi + if (( CURRENT == 1 )); then + _describe -t commands 'machinectl command' _machinectl_cmds || compadd "$@" else - _message "no more options" + local curcontext="$curcontext" + cmd="${${_machinectl_cmds[(r)$words[1]:*]%%:*}}" + if (( $#cmd )); then + if (( CURRENT == 2 )); then + case $cmd in + list*|cancel-transfer|pull-tar|pull-raw) + msg="no options" ;; + clone) + _machinectl_machines ;; + start) + _machinectl_machines ;; + *) + _sd_machines + esac + else + case $cmd in + copy-to|copy-from|bind) + _files ;; + *) msg="no options" + esac + fi + else + _message "no more options" + fi fi - fi } _arguments \ - {-h,--help}'[Prints a short help text and exits.]' \ - '--version[Prints a short version string and exits.]' \ - '--no-pager[Do not pipe output into a pager.]' \ - '--no-legend[Do not show the headers and footers.]' \ - '--no-ask-password[Do not ask for system passwords.]' \ - {-H+,--host=}'[Operate on remote host.]:userathost:_sd_hosts_or_user_at_host' \ - {-M+,--machine=}'[Operate on local container.]:machine:_sd_machines' \ - {-p+,--property=}'[Limit output to specified property.]:property:(Name Id Timestamp TimestampMonotonic Service Scope Leader Class State RootDirectory)' \ - {-a,--all}'[Show all properties.]' \ - {-q,--quiet}'[Suppress output.]' \ - {-l,--full}'[Do not ellipsize cgroup members.]' \ - '--kill-who=[Who to send signal to.]:killwho:(leader all)' \ - {-s+,--signal=}'[Which signal to send.]:signal:_signals' \ - '--read-only[Create read-only bind mount.]' \ - '--mkdir[Create directory before bind mounting, if missing.]' \ - {-n+,--lines=}'[Number of journal entries to show.]:integer' \ - {-o+,--output=}'[Change journal output mode.]:output modes:_sd_outputmodes' \ - '--verify=[Verification mode for downloaded images.]:verify:(no checksum signature)' \ - '--force[Download image even if already exists.]' \ - '*::machinectl command:_machinectl_commands' + {-h,--help}'[Prints a short help text and exits.]' \ + '--version[Prints a short version string and exits.]' \ + '--no-pager[Do not pipe output into a pager.]' \ + '--no-legend[Do not show the headers and footers.]' \ + '--no-ask-password[Do not ask for system passwords.]' \ + {-H+,--host=}'[Operate on remote host.]:userathost:_sd_hosts_or_user_at_host' \ + {-M+,--machine=}'[Operate on local container.]:machine:_sd_machines' \ + {-p+,--property=}'[Limit output to specified property.]:property:(Name Id Timestamp TimestampMonotonic Service Scope Leader Class State RootDirectory)' \ + {-a,--all}'[Show all properties.]' \ + {-q,--quiet}'[Suppress output.]' \ + {-l,--full}'[Do not ellipsize cgroup members.]' \ + '--kill-who=[Who to send signal to.]:killwho:(leader all)' \ + {-s+,--signal=}'[Which signal to send.]:signal:_signals' \ + '--read-only[Create read-only bind mount.]' \ + '--mkdir[Create directory before bind mounting, if missing.]' \ + {-n+,--lines=}'[Number of journal entries to show.]:integer' \ + {-o+,--output=}'[Change journal output mode.]:output modes:_sd_outputmodes' \ + '--verify=[Verification mode for downloaded images.]:verify:(no checksum signature)' \ + '--force[Download image even if already exists.]' \ + '*::machinectl command:_machinectl_commands' diff --git a/shell-completion/zsh/_networkctl b/shell-completion/zsh/_networkctl index ab62a6d9bf..c9b730fbe3 100644 --- a/shell-completion/zsh/_networkctl +++ b/shell-completion/zsh/_networkctl @@ -2,32 +2,32 @@ # SPDX-License-Identifier: LGPL-2.1+ (( $+functions[_networkctl_commands] )) || -_networkctl_commands(){ - local -a _networkctl_cmds - _networkctl_cmds=( + _networkctl_commands() { + local -a _networkctl_cmds + _networkctl_cmds=( 'list:List existing links' 'status:Show information about the specified links' 'lldp:Show Link Layer Discovery Protocol status' 'label:Show address labels' - ) - if (( CURRENT == 1 )); then - _describe -t commands 'networkctl command' _networkctl_cmds - else - local curcontext="$curcontext" - local -a _links - cmd="${${_networkctl_cmds[(r)$words[1]:*]%%:*}}" - if [ $cmd = "status" ]; then - _links=( "${(foa)$(networkctl list --no-legend | awk 'BEGIN{OFS=":"} {sub(/[[ \t]+/, ""); print $2,$0}' 2>/dev/null)}" ) - if [[ -n "$_links" ]]; then - _describe -t links 'links' _links + ) + if (( CURRENT == 1 )); then + _describe -t commands 'networkctl command' _networkctl_cmds + else + local curcontext="$curcontext" + local -a _links + cmd="${${_networkctl_cmds[(r)$words[1]:*]%%:*}}" + if [ $cmd = "status" ]; then + _links=( "${(foa)$(networkctl list --no-legend | awk 'BEGIN{OFS=":"} {sub(/[[ \t]+/, ""); print $2,$0}' 2>/dev/null)}" ) + if [[ -n "$_links" ]]; then + _describe -t links 'links' _links + else + _message "no links" + fi else - _message "no links" + _message "no more options" fi - else - _message "no more options" fi - fi -} + } _arguments \ {-a,--all}'[Show all links with status]' \ diff --git a/shell-completion/zsh/_sd_hosts_or_user_at_host b/shell-completion/zsh/_sd_hosts_or_user_at_host index 11f94f1976..a510bf3cf1 100644 --- a/shell-completion/zsh/_sd_hosts_or_user_at_host +++ b/shell-completion/zsh/_sd_hosts_or_user_at_host @@ -2,5 +2,5 @@ # SPDX-License-Identifier: LGPL-2.1+ _alternative \ - 'users-hosts:: _user_at_host' \ - 'hosts:: _hosts' + 'users-hosts:: _user_at_host' \ + 'hosts:: _hosts' diff --git a/shell-completion/zsh/_sd_machines b/shell-completion/zsh/_sd_machines index e783620b97..30b7fd81a3 100644 --- a/shell-completion/zsh/_sd_machines +++ b/shell-completion/zsh/_sd_machines @@ -2,15 +2,15 @@ # SPDX-License-Identifier: LGPL-2.1+ (( $+functions[__sd_machines_get_machines] )) || -__sd_machines_get_machines () { + __sd_machines_get_machines () { machinectl --full --no-legend --no-pager list | {while read -r a b; do echo $a; done;}; -} + } local -a _machines _machines=("${(fo)$(__sd_machines_get_machines)}") typeset -U _machines if [[ -n "$_machines" ]]; then - _describe 'machines' _machines + _describe 'machines' _machines else - _message 'no machines' + _message 'no machines' fi diff --git a/shell-completion/zsh/_systemctl.in b/shell-completion/zsh/_systemctl.in index 590fc49604..0c86fec95c 100644 --- a/shell-completion/zsh/_systemctl.in +++ b/shell-completion/zsh/_systemctl.in @@ -3,197 +3,197 @@ (( $+functions[_systemctl_commands] )) || _systemctl_commands() { - local -a _systemctl_cmds - _systemctl_cmds=( - "list-sockets:List sockets" - "list-timers:List timers" - "list-units:List units" - "start:Start (activate) one or more units" - "stop:Stop (deactivate) one or more units" - "reload:Reload one or more units" - "restart:Start or restart one or more units" - "condrestart:Restart one or more units if active" - "try-restart:Restart one or more units if active" - "reload-or-restart:Reload one or more units if possible, otherwise start or restart" - "force-reload:Reload one or more units if possible, otherwise restart if active" - "hibernate:Hibernate the system" - "hybrid-sleep:Hibernate and suspend the system" - "suspend-then-hibernate:Suspend the system for a period of time, and then hibernate it" - "try-reload-or-restart:Reload one or more units if possible, otherwise restart if active" - "isolate:Start one unit and stop all others" - "kill:Send signal to processes of a unit" - "is-active:Check whether units are active" - "is-failed:Check whether units are failed" - "status:Show runtime status of one or more units" - "show:Show properties of one or more units/jobs or the manager" - "cat:Show the source unit files and drop-ins" - "reset-failed:Reset failed state for all, one, or more units" - "list-unit-files:List installed unit files" - "enable:Enable one or more unit files" - "disable:Disable one or more unit files" - "add-wants:Add Wants= dependencies to a unit" - "add-requires:Add Requires= dependencies to a unit" - "reenable:Reenable one or more unit files" - "preset:Enable/disable one or more unit files based on preset configuration" - "set-default:Set the default target" - "get-default:Query the default target" - "edit:Edit one or more unit files" - "is-system-running:Query overall status of the system" - "help:Show documentation for specified units" - "list-dependencies:Show unit dependency tree" - "mask:Mask one or more units" - "unmask:Unmask one or more units" - "link:Link one or more units files into the search path" - "is-enabled:Check whether unit files are enabled" - "list-jobs:List jobs" - "cancel:Cancel all, one, or more jobs" - "show-environment:Dump environment" - "set-environment:Set one or more environment variables" - "unset-environment:Unset one or more environment variables" - "daemon-reload:Reload systemd manager configuration" - "daemon-reexec:Reexecute systemd manager" - "default:Enter system default mode" - "rescue:Enter system rescue mode" - "emergency:Enter system emergency mode" - "halt:Shut down and halt the system" - "suspend:Suspend the system" - "poweroff:Shut down and power-off the system" - "reboot:Shut down and reboot the system" - "kexec:Shut down and reboot the system with kexec" - "exit:Ask for user instance termination" - "switch-root:Change root directory" - "revert:Revert unit files to their vendor versions" - "set-property:Sets one or more properties of a unit" - ) - - if (( CURRENT == 1 )); then - _describe -t commands 'systemctl command' _systemctl_cmds || compadd "$@" - else - local curcontext="$curcontext" expl - - cmd="${${_systemctl_cmds[(r)$words[1]:*]%%:*}}" - # Deal with any aliases - case $cmd in - condrestart) cmd="try-restart";; - force-reload) cmd="try-reload-or-restart";; - esac - - if (( $#cmd )); then - curcontext="${curcontext%:*:*}:systemctl-${cmd}:" - - local update_policy - zstyle -s ":completion:${curcontext}:" cache-policy update_policy - if [[ -z "$update_policy" ]]; then - zstyle ":completion:${curcontext}:" cache-policy _systemctl_caching_policy - fi - - _call_function ret _systemctl_$cmd || _message 'no more arguments' + local -a _systemctl_cmds + _systemctl_cmds=( + "list-sockets:List sockets" + "list-timers:List timers" + "list-units:List units" + "start:Start (activate) one or more units" + "stop:Stop (deactivate) one or more units" + "reload:Reload one or more units" + "restart:Start or restart one or more units" + "condrestart:Restart one or more units if active" + "try-restart:Restart one or more units if active" + "reload-or-restart:Reload one or more units if possible, otherwise start or restart" + "force-reload:Reload one or more units if possible, otherwise restart if active" + "hibernate:Hibernate the system" + "hybrid-sleep:Hibernate and suspend the system" + "suspend-then-hibernate:Suspend the system for a period of time, and then hibernate it" + "try-reload-or-restart:Reload one or more units if possible, otherwise restart if active" + "isolate:Start one unit and stop all others" + "kill:Send signal to processes of a unit" + "is-active:Check whether units are active" + "is-failed:Check whether units are failed" + "status:Show runtime status of one or more units" + "show:Show properties of one or more units/jobs or the manager" + "cat:Show the source unit files and drop-ins" + "reset-failed:Reset failed state for all, one, or more units" + "list-unit-files:List installed unit files" + "enable:Enable one or more unit files" + "disable:Disable one or more unit files" + "add-wants:Add Wants= dependencies to a unit" + "add-requires:Add Requires= dependencies to a unit" + "reenable:Reenable one or more unit files" + "preset:Enable/disable one or more unit files based on preset configuration" + "set-default:Set the default target" + "get-default:Query the default target" + "edit:Edit one or more unit files" + "is-system-running:Query overall status of the system" + "help:Show documentation for specified units" + "list-dependencies:Show unit dependency tree" + "mask:Mask one or more units" + "unmask:Unmask one or more units" + "link:Link one or more units files into the search path" + "is-enabled:Check whether unit files are enabled" + "list-jobs:List jobs" + "cancel:Cancel all, one, or more jobs" + "show-environment:Dump environment" + "set-environment:Set one or more environment variables" + "unset-environment:Unset one or more environment variables" + "daemon-reload:Reload systemd manager configuration" + "daemon-reexec:Reexecute systemd manager" + "default:Enter system default mode" + "rescue:Enter system rescue mode" + "emergency:Enter system emergency mode" + "halt:Shut down and halt the system" + "suspend:Suspend the system" + "poweroff:Shut down and power-off the system" + "reboot:Shut down and reboot the system" + "kexec:Shut down and reboot the system with kexec" + "exit:Ask for user instance termination" + "switch-root:Change root directory" + "revert:Revert unit files to their vendor versions" + "set-property:Sets one or more properties of a unit" + ) + + if (( CURRENT == 1 )); then + _describe -t commands 'systemctl command' _systemctl_cmds || compadd "$@" else - _message "unknown systemctl command: $words[1]" + local curcontext="$curcontext" expl + + cmd="${${_systemctl_cmds[(r)$words[1]:*]%%:*}}" + # Deal with any aliases + case $cmd in + condrestart) cmd="try-restart";; + force-reload) cmd="try-reload-or-restart";; + esac + + if (( $#cmd )); then + curcontext="${curcontext%:*:*}:systemctl-${cmd}:" + + local update_policy + zstyle -s ":completion:${curcontext}:" cache-policy update_policy + if [[ -z "$update_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy _systemctl_caching_policy + fi + + _call_function ret _systemctl_$cmd || _message 'no more arguments' + else + _message "unknown systemctl command: $words[1]" + fi + return ret fi - return ret - fi } # @todo _systemd-run has a helper with the same name, so we must redefine __systemctl() { - systemctl $_sys_service_mgr --full --no-legend --no-pager "$@" 2>/dev/null + systemctl $_sys_service_mgr --full --no-legend --no-pager "$@" 2>/dev/null } # Fills the unit list (( $+functions[_systemctl_all_units] )) || -_systemctl_all_units() + _systemctl_all_units() { - if ( [[ ${+_sys_all_units} -eq 0 ]] || _cache_invalid SYS_ALL_UNITS$_sys_service_mgr ) || - ! _retrieve_cache SYS_ALL_UNITS$_sys_service_mgr; - then - _sys_all_units=( ${${(f)"$(__systemctl list-units --all "$PREFIX*" )"}%% *} ) - _store_cache SYS_ALL_UNITS$_sys_service_mgr _sys_all_units - fi + if ( [[ ${+_sys_all_units} -eq 0 ]] || _cache_invalid SYS_ALL_UNITS$_sys_service_mgr ) || + ! _retrieve_cache SYS_ALL_UNITS$_sys_service_mgr; + then + _sys_all_units=( ${${(f)"$(__systemctl list-units --all "$PREFIX*" )"}%% *} ) + _store_cache SYS_ALL_UNITS$_sys_service_mgr _sys_all_units + fi } # Fills the unit list including all file units (( $+functions[_systemctl_really_all_units] )) || -_systemctl_really_all_units() + _systemctl_really_all_units() { - local -a all_unit_files; - local -a really_all_units; - if ( [[ ${+_sys_really_all_units} -eq 0 ]] || _cache_invalid SYS_REALLY_ALL_UNITS$_sys_service_mgr ) || - ! _retrieve_cache SYS_REALLY_ALL_UNITS$_sys_service_mgr; - then - all_unit_files=( ${${(f)"$(__systemctl list-unit-files "$PREFIX*" )"}%% *} ) - _systemctl_all_units - really_all_units=($_sys_all_units $all_unit_files) - _sys_really_all_units=(${(u)really_all_units}) - _store_cache SYS_REALLY_ALL_UNITS$_sys_service_mgr _sys_really_all_units - fi + local -a all_unit_files; + local -a really_all_units; + if ( [[ ${+_sys_really_all_units} -eq 0 ]] || _cache_invalid SYS_REALLY_ALL_UNITS$_sys_service_mgr ) || + ! _retrieve_cache SYS_REALLY_ALL_UNITS$_sys_service_mgr; + then + all_unit_files=( ${${(f)"$(__systemctl list-unit-files "$PREFIX*" )"}%% *} ) + _systemctl_all_units + really_all_units=($_sys_all_units $all_unit_files) + _sys_really_all_units=(${(u)really_all_units}) + _store_cache SYS_REALLY_ALL_UNITS$_sys_service_mgr _sys_really_all_units + fi } (( $+functions[_filter_units_by_property] )) || -_filter_units_by_property() { - local property=$1 value=$2; shift 2 - local -a units; units=("${(q-)@}") - local -A props - props=(${(f)"$(_call_program units "$service $_sys_service_mgr show --no-pager --property=\"Id,$property\" -- ${units} 2>/dev/null")"}) - echo -E - "${(@g:o:)${(k@)props[(Re)$property=$value]}#Id=}" -} + _filter_units_by_property() { + local property=$1 value=$2; shift 2 + local -a units; units=("${(q-)@}") + local -A props + props=(${(f)"$(_call_program units "$service $_sys_service_mgr show --no-pager --property=\"Id,$property\" -- ${units} 2>/dev/null")"}) + echo -E - "${(@g:o:)${(k@)props[(Re)$property=$value]}#Id=}" + } (( $+functions[_systemctl_get_non_template_names] )) || -_systemctl_get_non_template_names() { echo -E - ${^${(R)${(f)"$( + _systemctl_get_non_template_names() { echo -E - ${^${(R)${(f)"$( __systemctl $mode list-unit-files "$PREFIX*" __systemctl $mode list-units --all "$PREFIX*" )"}:#*@.*}%%[[:space:]]*} } (( $+functions[_systemctl_get_template_names] )) || -_systemctl_get_template_names() { echo -E - ${^${(M)${(f)"$(__systemctl list-unit-files "$PREFIX*" )"}##*@.[^[:space:]]##}%%@.*}\@ } + _systemctl_get_template_names() { echo -E - ${^${(M)${(f)"$(__systemctl list-unit-files "$PREFIX*" )"}##*@.[^[:space:]]##}%%@.*}\@ } (( $+functions[_systemctl_active_units] )) || -_systemctl_active_units() {_sys_active_units=( ${${(f)"$(__systemctl list-units "$PREFIX*" )"}%% *} )} + _systemctl_active_units() {_sys_active_units=( ${${(f)"$(__systemctl list-units "$PREFIX*" )"}%% *} )} (( $+functions[_systemctl_startable_units] )) || -_systemctl_startable_units(){ - _sys_startable_units=( $( _filter_units_by_property ActiveState inactive $( - _filter_units_by_property CanStart yes ${${${(f)"$( + _systemctl_startable_units(){ + _sys_startable_units=( $( _filter_units_by_property ActiveState inactive $( + _filter_units_by_property CanStart yes ${${${(f)"$( __systemctl $mode list-unit-files --state enabled,enabled-runtime,linked,linked-runtime,static,indirect,disabled,generated,transient "$PREFIX*" __systemctl $mode list-units --state inactive,failed "$PREFIX*" )"}:#*@.*}%%[[:space:]]*} - )) ) -} + )) ) + } (( $+functions[_systemctl_restartable_units] )) || -_systemctl_restartable_units(){ - _sys_restartable_units=( $( _filter_units_by_property CanStart yes ${${${(f)"$( + _systemctl_restartable_units(){ + _sys_restartable_units=( $( _filter_units_by_property CanStart yes ${${${(f)"$( __systemctl $mode list-unit-files --state enabled,disabled,static "$PREFIX*" __systemctl $mode list-units "$PREFIX*" )"}:#*@.*}%%[[:space:]]*} ) ) -} + } (( $+functions[_systemctl_failed_units] )) || -_systemctl_failed_units() {_sys_failed_units=( ${${(f)"$(__systemctl list-units --state=failed "$PREFIX*" )"}%% *} ) } + _systemctl_failed_units() {_sys_failed_units=( ${${(f)"$(__systemctl list-units --state=failed "$PREFIX*" )"}%% *} ) } (( $+functions[_systemctl_unit_state] )) || -_systemctl_unit_state() { typeset -gA _sys_unit_state; _sys_unit_state=( $(__systemctl list-unit-files "$PREFIX*" ) ) } + _systemctl_unit_state() { typeset -gA _sys_unit_state; _sys_unit_state=( $(__systemctl list-unit-files "$PREFIX*" ) ) } local fun # Completion functions for ALL_UNITS for fun in cat mask ; do - (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() - { - _systemctl_really_all_units - _wanted systemd-units expl unit \ - compadd "$@" -a - _sys_really_all_units - } + (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() + { + _systemctl_really_all_units + _wanted systemd-units expl unit \ + compadd "$@" -a - _sys_really_all_units + } 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 set-property; do - (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() - { - _wanted systemd-units expl unit \ - compadd "$@" - $(_systemctl_get_non_template_names) - } + (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() + { + _wanted systemd-units expl unit \ + compadd "$@" - $(_systemctl_get_non_template_names) + } done # Completion functions for ENABLED_UNITS @@ -201,126 +201,126 @@ done { local _sys_unit_state; _systemctl_unit_state _wanted systemd-units expl 'enabled unit' \ - compadd "$@" - ${(k)_sys_unit_state[(R)enabled]} + compadd "$@" - ${(k)_sys_unit_state[(R)enabled]} } (( $+functions[_systemctl_reenable] )) || _systemctl_reenable() { local _sys_unit_state; _systemctl_unit_state _wanted systemd-units expl 'enabled/disabled unit' \ - compadd "$@" - ${(k)_sys_unit_state[(R)(enabled|disabled)]} $(_systemctl_get_template_names) + compadd "$@" - ${(k)_sys_unit_state[(R)(enabled|disabled)]} $(_systemctl_get_template_names) } # Completion functions for DISABLED_UNITS (( $+functions[_systemctl_enable] )) || _systemctl_enable() { - local _sys_unit_state; _systemctl_unit_state - _wanted systemd-units expl 'disabled unit' \ - compadd "$@" - ${(k)_sys_unit_state[(R)disabled]} $(_systemctl_get_template_names) + local _sys_unit_state; _systemctl_unit_state + _wanted systemd-units expl 'disabled unit' \ + compadd "$@" - ${(k)_sys_unit_state[(R)disabled]} $(_systemctl_get_template_names) } # Completion functions for FAILED_UNITS (( $+functions[_systemctl_reset-failed] )) || _systemctl_reset-failed() { - local _sys_failed_units; _systemctl_failed_units - _wanted systemd-units expl 'failed unit' \ - compadd "$@" -a - _sys_failed_units || _message "no failed unit found" + local _sys_failed_units; _systemctl_failed_units + _wanted systemd-units expl 'failed unit' \ + compadd "$@" -a - _sys_failed_units || _message "no failed unit found" } # Completion functions for STARTABLE_UNITS (( $+functions[_systemctl_start] )) || _systemctl_start() { - local _sys_startable_units; _systemctl_startable_units - _wanted systemd-units expl 'startable unit' \ - compadd "$@" - ${_sys_startable_units[*]} + local _sys_startable_units; _systemctl_startable_units + _wanted systemd-units expl 'startable unit' \ + compadd "$@" - ${_sys_startable_units[*]} } # Completion functions for STOPPABLE_UNITS for fun in stop kill try-restart condrestart ; do - (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() - { - local _sys_active_units; _systemctl_active_units - _wanted systemd-units expl 'stoppable unit' \ - compadd "$@" - $( _filter_units_by_property CanStop yes \ - ${_sys_active_units[*]} ) - } + (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() + { + local _sys_active_units; _systemctl_active_units + _wanted systemd-units expl 'stoppable unit' \ + compadd "$@" - $( _filter_units_by_property CanStop yes \ + ${_sys_active_units[*]} ) + } done # Completion functions for ISOLATABLE_UNITS (( $+functions[_systemctl_isolate] )) || _systemctl_isolate() { - _systemctl_all_units - _wanted systemd-units expl 'isolatable unit' \ - compadd "$@" - $( _filter_units_by_property AllowIsolate yes \ - ${_sys_all_units[*]} ) + _systemctl_all_units + _wanted systemd-units expl 'isolatable unit' \ + compadd "$@" - $( _filter_units_by_property AllowIsolate yes \ + ${_sys_all_units[*]} ) } # Completion functions for RELOADABLE_UNITS for fun in reload try-reload-or-restart force-reload ; do - (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() - { - local _sys_active_units; _systemctl_active_units - _wanted systemd-units expl 'reloadable unit' \ - compadd "$@" - $( _filter_units_by_property CanReload yes \ - ${_sys_active_units[*]} ) - } + (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() + { + local _sys_active_units; _systemctl_active_units + _wanted systemd-units expl 'reloadable unit' \ + compadd "$@" - $( _filter_units_by_property CanReload yes \ + ${_sys_active_units[*]} ) + } done # Completion functions for RESTARTABLE_UNITS for fun in restart reload-or-restart ; do - (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() - { - local _sys_restartable_units; _systemctl_restartable_units - _wanted systemd-units expl 'restartable unit' \ - compadd "$@" - ${_sys_restartable_units[*]} - } + (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() + { + local _sys_restartable_units; _systemctl_restartable_units + _wanted systemd-units expl 'restartable unit' \ + compadd "$@" - ${_sys_restartable_units[*]} + } done # Completion functions for MASKED_UNITS (( $+functions[_systemctl_unmask] )) || _systemctl_unmask() { - local _sys_unit_state; _systemctl_unit_state - _wanted systemd-units expl 'masked unit' \ - compadd "$@" - ${(k)_sys_unit_state[(R)masked]} || _message "no masked units found" + local _sys_unit_state; _systemctl_unit_state + _wanted systemd-units expl 'masked unit' \ + compadd "$@" - ${(k)_sys_unit_state[(R)masked]} || _message "no masked units found" } # Completion functions for JOBS (( $+functions[_systemctl_cancel] )) || _systemctl_cancel() { - _wanted systemd-jobs expl job \ - compadd "$@" - ${${(f)"$(__systemctl list-jobs)"}%% *} || - _message "no jobs found" + _wanted systemd-jobs expl job \ + compadd "$@" - ${${(f)"$(__systemctl list-jobs)"}%% *} || + _message "no jobs found" } # Completion functions for TARGETS (( $+functions[_systemctl_set-default] )) || _systemctl_set-default() { - _wanted systemd-targets expl target \ - compadd "$@" - ${${(f)"$(__systemctl list-unit-files --type target --all "$PREFIX*" )"}%% *} || - _message "no targets found" + _wanted systemd-targets expl target \ + compadd "$@" - ${${(f)"$(__systemctl list-unit-files --type target --all "$PREFIX*" )"}%% *} || + _message "no targets found" } # Completion functions for ENVS for fun in set-environment unset-environment ; do - (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() - { - local fun=$0 ; fun=${fun##_systemctl_} - local suf - if [[ "${fun}" = "set-environment" ]]; then - suf='-S=' - fi - _wanted systemd-environment expl 'environment variable' \ - compadd "$@" ${suf} - ${${(f)"$(systemctl show-environment)"}%%=*} - } + (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() + { + local fun=$0 ; fun=${fun##_systemctl_} + local suf + if [[ "${fun}" = "set-environment" ]]; then + suf='-S=' + fi + _wanted systemd-environment expl 'environment variable' \ + compadd "$@" ${suf} - ${${(f)"$(systemctl show-environment)"}%%=*} + } done (( $+functions[_systemctl_link] )) || _systemctl_link() { - _sd_unit_files -} + _sd_unit_files + } (( $+functions[_systemctl_switch-root] )) || _systemctl_switch-root() { - _files -} + _files + } # no systemctl completion for: # [STANDALONE]='daemon-reexec daemon-reload default @@ -328,57 +328,57 @@ done # list-unit-files poweroff reboot rescue show-environment' (( $+functions[_systemctl_caching_policy] )) || -_systemctl_caching_policy() + _systemctl_caching_policy() { - local _sysunits - local -a oldcache + local _sysunits + local -a oldcache - # rebuild if cache is more than a day old - oldcache=( "$1"(mh+1) ) - (( $#oldcache )) && return 0 + # rebuild if cache is more than a day old + oldcache=( "$1"(mh+1) ) + (( $#oldcache )) && return 0 - _sysunits=(${${(f)"$(__systemctl --all)"}%% *}) + _sysunits=(${${(f)"$(__systemctl --all)"}%% *}) - if (( $#_sysunits )); then - for unit in $_sysunits; do - [[ "$unit" -nt "$1" ]] && return 0 - done - fi + if (( $#_sysunits )); then + for unit in $_sysunits; do + [[ "$unit" -nt "$1" ]] && return 0 + done + fi - return 1 + return 1 } (( $+functions[_systemctl_unit_states] )) || -_systemctl_unit_states() { - local -a _states - _states=("${(fo)$(__systemctl --state=help)}") - _values -s , "${_states[@]}" -} + _systemctl_unit_states() { + local -a _states + _states=("${(fo)$(__systemctl --state=help)}") + _values -s , "${_states[@]}" + } (( $+functions[_systemctl_unit_types] )) || -_systemctl_unit_types() { - local -a _types - _types=("${(fo)$(__systemctl -t help)}") - _values -s , "${_types[@]}" -} + _systemctl_unit_types() { + local -a _types + _types=("${(fo)$(__systemctl -t help)}") + _values -s , "${_types[@]}" + } (( $+functions[_systemctl_unit_properties] )) || -_systemctl_unit_properties() { - if ( [[ ${+_sys_all_properties} -eq 0 ]] || _cache_invalid SYS_ALL_PROPERTIES$_sys_service_mgr ) || - ! _retrieve_cache SYS_ALL_PROPERTIES$_sys_service_mgr; - then - _sys_all_properties=( ${${(M)${(f)"$(@rootlibexecdir@/systemd --dump-bus-properties)"}}} ) - _store_cache SYS_ALL_PROPERTIES$_sys_service_mgr _sys_all_properties - fi - _values -s , "${_sys_all_properties[@]}" -} + _systemctl_unit_properties() { + if ( [[ ${+_sys_all_properties} -eq 0 ]] || _cache_invalid SYS_ALL_PROPERTIES$_sys_service_mgr ) || + ! _retrieve_cache SYS_ALL_PROPERTIES$_sys_service_mgr; + then + _sys_all_properties=( ${${(M)${(f)"$(@rootlibexecdir@/systemd --dump-bus-properties)"}}} ) + _store_cache SYS_ALL_PROPERTIES$_sys_service_mgr _sys_all_properties + fi + _values -s , "${_sys_all_properties[@]}" + } (( $+functions[_systemctl_job_modes] )) || -_systemctl_job_modes() { - local -a _modes - _modes=(fail replace replace-irreversibly isolate ignore-dependencies ignore-requirements flush) - _values -s , "${_modes[@]}" -} + _systemctl_job_modes() { + local -a _modes + _modes=(fail replace replace-irreversibly isolate ignore-dependencies ignore-requirements flush) + _values -s , "${_modes[@]}" + } # Build arguments for "systemctl" to be used in completion. local -a _modes; _modes=("--user" "--system") diff --git a/shell-completion/zsh/_systemd b/shell-completion/zsh/_systemd index ccac889244..cd674a71ea 100644 --- a/shell-completion/zsh/_systemd +++ b/shell-completion/zsh/_systemd @@ -11,7 +11,7 @@ case "$service" in '--no-tty[Ask question via agent even on TTY]' \ '--accept-cached[Accept cached passwords]' \ '--multiple[List multiple passwords if available]' - ;; + ;; systemd-cat) _arguments \ {-h,--help}'[Show this help]' \ @@ -20,7 +20,7 @@ case "$service" in {-p+,--priority=}'[Set priority value.]:value:({0..7})' \ '--level-prefix=[Control whether level prefix shall be parsed.]:boolean:(1 0)' \ ':Message' - ;; + ;; systemd-cgls) _arguments \ {-h,--help}'[Show this help]' \ @@ -29,7 +29,7 @@ case "$service" in {-a,--all}'[Show all groups, including empty]' \ '-k[Include kernel threads in output]' \ ':cgroups:(cpuset cpu cpuacct memory devices freezer blkio)' - ;; + ;; systemd-cgtop) _arguments \ {-h,--help}'[Show this help]' \ @@ -43,7 +43,7 @@ case "$service" in {-n+,--iterations=}'[Run for N iterations before exiting]:number of iterations:' \ {-b,--batch}'[Run in batch mode, accepting no input]' \ '--depth=[Maximum traversal depth]:maximum depth:' - ;; + ;; systemd-detect-virt) _arguments \ {-h,--help}'[Show this help]' \ @@ -51,12 +51,12 @@ case "$service" in {-c,--container}'[Only detect whether we are run in a container]' \ {-v,--vm}'[Only detect whether we are run in a VM]' \ {-q,--quiet}"[Don't output anything, just set return value]" - ;; + ;; systemd-machine-id-setup) _arguments \ {-h,--help}'[Show this help]' \ '--version[Show package version]' - ;; + ;; systemd-notify) _arguments \ {-h,--help}'[Show this help]' \ @@ -65,7 +65,7 @@ case "$service" in '--pid=[Inform the init system about the main PID of the daemon]:daemon main PID:_pids' \ '--status=[Send a free-form status string for the daemon to the init systemd]:status string:' \ '--booted[Returns 0 if the system was booted up with systemd]' - ;; + ;; systemd-tty-ask-password-agent) _arguments \ {-h,--help}'[Prints a short help text and exits.]' \ @@ -76,8 +76,6 @@ case "$service" in '--wall[Forward password requests to wall(1).]' \ '--plymouth[Ask question with plymouth(8).]' \ '--console[Ask question on /dev/console.]' - ;; + ;; *) _message 'eh?' ;; esac - -#vim: set ft=zsh sw=4 ts=4 et diff --git a/shell-completion/zsh/_systemd-analyze b/shell-completion/zsh/_systemd-analyze index 64d418e643..8a5fbb5124 100644 --- a/shell-completion/zsh/_systemd-analyze +++ b/shell-completion/zsh/_systemd-analyze @@ -2,67 +2,67 @@ # SPDX-License-Identifier: LGPL-2.1+ (( $+functions[_systemd-analyze_log-level] )) || -_systemd-analyze_log-level() { - local -a _levels - _levels=(debug info notice warning err crit alert emerg) - _describe -t level 'logging level' _levels || compadd "$@" -} + _systemd-analyze_log-level() { + local -a _levels + _levels=(debug info notice warning err crit alert emerg) + _describe -t level 'logging level' _levels || compadd "$@" + } (( $+functions[_systemd-analyze_log-target] )) || -_systemd-analyze_log-target() { - local -a _targets - _targets=(console journal kmsg journal-or-kmsg null) - _describe -t target 'logging target' _targets || compadd "$@" -} + _systemd-analyze_log-target() { + local -a _targets + _targets=(console journal kmsg journal-or-kmsg null) + _describe -t target 'logging target' _targets || compadd "$@" + } (( $+functions[_systemd-analyze_verify] )) || -_systemd-analyze_verify() { - _sd_unit_files -} + _systemd-analyze_verify() { + _sd_unit_files + } (( $+functions[_systemd-analyze_service-watchdogs] )) || -_systemd-analyze_service-watchdogs() { - local -a _states - _states=(on off) - _describe -t state 'state' _states || compadd "$@" -} + _systemd-analyze_service-watchdogs() { + local -a _states + _states=(on off) + _describe -t state 'state' _states || compadd "$@" + } (( $+functions[_systemd-analyze_commands] )) || -_systemd-analyze_commands(){ - local -a _systemd_analyze_cmds - # Descriptions taken from systemd-analyze --help. - _systemd_analyze_cmds=( - 'time:Print time spent in the kernel before reaching userspace' - 'blame:Print list of running units ordered by time to init' - 'critical-chain:Print a tree of the time critical chain of units' - 'plot:Output SVG graphic showing service initialization' - 'dot:Dump dependency graph (in dot(1) format)' - 'dump:Dump server status' - 'unit-paths:List unit load paths' - 'log-level:Get/set systemd log threshold' - 'log-target:Get/set systemd log target' - 'service-watchdogs:Get/set service watchdog status' - 'syscall-filter:List syscalls in seccomp filter' - 'verify:Check unit files for correctness' - 'calendar:Validate repetitive calendar time events' - ) + _systemd-analyze_commands(){ + local -a _systemd_analyze_cmds + # Descriptions taken from systemd-analyze --help. + _systemd_analyze_cmds=( + 'time:Print time spent in the kernel before reaching userspace' + 'blame:Print list of running units ordered by time to init' + 'critical-chain:Print a tree of the time critical chain of units' + 'plot:Output SVG graphic showing service initialization' + 'dot:Dump dependency graph (in dot(1) format)' + 'dump:Dump server status' + 'unit-paths:List unit load paths' + 'log-level:Get/set systemd log threshold' + 'log-target:Get/set systemd log target' + 'service-watchdogs:Get/set service watchdog status' + 'syscall-filter:List syscalls in seccomp filter' + 'verify:Check unit files for correctness' + 'calendar:Validate repetitive calendar time events' + ) - if (( CURRENT == 1 )); then - _describe "options" _systemd_analyze_cmds - else - local curcontext="$curcontext" - cmd="${${_systemd_analyze_cmds[(r)$words[1]:*]%%:*}}" - if (( $#cmd )); then - if (( $+functions[_systemd-analyze_$cmd] )) && (( CURRENT == 2 )); then - _systemd-analyze_$cmd + if (( CURRENT == 1 )); then + _describe "options" _systemd_analyze_cmds + else + local curcontext="$curcontext" + cmd="${${_systemd_analyze_cmds[(r)$words[1]:*]%%:*}}" + if (( $#cmd )); then + if (( $+functions[_systemd-analyze_$cmd] )) && (( CURRENT == 2 )); then + _systemd-analyze_$cmd + else + _message "no more options" + fi else - _message "no more options" + _message "unknown systemd-analyze command: $words[1]" fi - else - _message "unknown systemd-analyze command: $words[1]" fi - fi -} + } _arguments \ {-h,--help}'[Show help text]' \ diff --git a/shell-completion/zsh/_systemd-resolve b/shell-completion/zsh/_systemd-resolve index c4664422ec..07f6ad26b5 100644 --- a/shell-completion/zsh/_systemd-resolve +++ b/shell-completion/zsh/_systemd-resolve @@ -1,6 +1,5 @@ #compdef systemd-resolve # SPDX-License-Identifier: LGPL-2.1+ - # # This file is part of systemd. # @@ -18,32 +17,32 @@ # along with systemd; If not, see <http://www.gnu.org/licenses/>. (( $+functions[_systemd-resolve_protocols] )) || -_systemd-resolve_protocols() { - local -a _protocol - _protocol=( $(_call_program protocol ${service} --legend=no --protocol help; echo help) ) - _values 'protocol' "$_protocol[@]" -} + _systemd-resolve_protocols() { + local -a _protocol + _protocol=( $(_call_program protocol ${service} --legend=no --protocol help; echo help) ) + _values 'protocol' "$_protocol[@]" + } (( $+functions[_systemd-resolve_types] )) || -_systemd-resolve_types() { - local -a _type - _type=( $(_call_program type ${service} --legend=no --type help; echo help) ) - _values 'type' "$_type[@]" -} + _systemd-resolve_types() { + local -a _type + _type=( $(_call_program type ${service} --legend=no --type help; echo help) ) + _values 'type' "$_type[@]" + } (( $+functions[_systemd-resolve_classes] )) || -_systemd-resolve_classes() { - local -a _class - _class=( $(_call_program class ${service} --legend=no --class help; echo help) ) - _values 'class' "$_class[@]" -} + _systemd-resolve_classes() { + local -a _class + _class=( $(_call_program class ${service} --legend=no --class help; echo help) ) + _values 'class' "$_class[@]" + } (( $+functions[_systemd-resolve_none] )) || -_systemd-resolve_none() { - _alternative : \ - 'domain:DNS address:' \ - 'address:email address:' -} + _systemd-resolve_none() { + _alternative : \ + 'domain:DNS address:' \ + 'address:email address:' + } _arguments \ {-h,--help}'[Print a short help text and exit]' \ diff --git a/shell-completion/zsh/_systemd-run b/shell-completion/zsh/_systemd-run index 81017180a7..2e0b3d2cfd 100644 --- a/shell-completion/zsh/_systemd-run +++ b/shell-completion/zsh/_systemd-run @@ -3,34 +3,34 @@ # @todo _systemctl has a helper with the same name, so we must redefine __systemctl() { - local -a _modes - _modes=("--user" "--system") - systemctl ${words:*_modes} --full --no-legend --no-pager "$@" 2>/dev/null + local -a _modes + _modes=("--user" "--system") + systemctl ${words:*_modes} --full --no-legend --no-pager "$@" 2>/dev/null } (( $+functions[__systemd-run_get_slices] )) || -__systemd-run_get_slices () { + __systemd-run_get_slices () { __systemctl list-units --all -t slice \ - | { while read -r a b; do echo $a; done; }; -} + | { while read -r a b; do echo $a; done; }; + } (( $+functions[__systemd-run_slices] )) || -__systemd-run_slices () { + __systemd-run_slices () { local -a _slices _slices=(${(fo)"$(__systemd-run_get_slices)"}) typeset -U _slices _describe 'slices' _slices -} + } _arguments \ - {-h,--help}'[Show help message]' \ - '--version[Show package version]' \ - '--user[Run as user unit]' \ - {-H+,--host=}'[Operate on remote host]:[user@]host:_sd_hosts_or_user_at_host' \ - {-M+,--machine=}'[Operate on local container]:machines:_sd_machines' \ - '--scope[Run this as scope rather than service]' \ - '--unit=[Run under the specified unit name]:unit name' \ - {-p+,--property=}'[Set unit property]:NAME=VALUE:(( \ + {-h,--help}'[Show help message]' \ + '--version[Show package version]' \ + '--user[Run as user unit]' \ + {-H+,--host=}'[Operate on remote host]:[user@]host:_sd_hosts_or_user_at_host' \ + {-M+,--machine=}'[Operate on local container]:machines:_sd_machines' \ + '--scope[Run this as scope rather than service]' \ + '--unit=[Run under the specified unit name]:unit name' \ + {-p+,--property=}'[Set unit property]:NAME=VALUE:(( \ CPUAccounting= MemoryAccounting= BlockIOAccounting= SendSIGHUP= \ SendSIGKILL= MemoryLimit= CPUShares= BlockIOWeight= User= Group= \ DevicePolicy= KillMode= DeviceAllow= BlockIOReadBandwidth= \ @@ -45,21 +45,21 @@ _arguments \ ReadOnlyPaths= InaccessiblePaths= EnvironmentFile= \ ProtectSystem= ProtectHome= RuntimeDirectory= PassEnvironment= \ ))' \ - '--description=[Description for unit]:description' \ - '--slice=[Run in the specified slice]:slices:__systemd-run_slices' \ - {-r,--remain-after-exit}'[Leave service around until explicitly stopped]' \ - '--send-sighup[Send SIGHUP when terminating]' \ - '--service-type=[Service type]:type:(simple forking oneshot dbus notify idle)' \ - '--uid=[Run as system user]:user:_users' \ - '--gid=[Run as system group]:group:_groups' \ - '--nice=[Nice level]:nice level' \ - '--setenv=[Set environment]:NAME=VALUE' \ - '--on-active=[Run after SEC seconds]:SEC' \ - '--on-boot=[Run SEC seconds after machine was booted up]:SEC' \ - '--on-startup=[Run SEC seconds after systemd was first started]:SEC' \ - '--on-unit-active=[Run SEC seconds after the last activation]:SEC' \ - '--on-unit-inactive=[Run SEC seconds after the last deactivation]:SEC' \ - '--on-calendar=[Realtime timer]:SPEC' \ - '--timer-property=[Set timer unit property]:NAME=VALUE' \ - '--wait=[Wait until service stopped again]' \ - '*::command:_command' + '--description=[Description for unit]:description' \ + '--slice=[Run in the specified slice]:slices:__systemd-run_slices' \ + {-r,--remain-after-exit}'[Leave service around until explicitly stopped]' \ + '--send-sighup[Send SIGHUP when terminating]' \ + '--service-type=[Service type]:type:(simple forking oneshot dbus notify idle)' \ + '--uid=[Run as system user]:user:_users' \ + '--gid=[Run as system group]:group:_groups' \ + '--nice=[Nice level]:nice level' \ + '--setenv=[Set environment]:NAME=VALUE' \ + '--on-active=[Run after SEC seconds]:SEC' \ + '--on-boot=[Run SEC seconds after machine was booted up]:SEC' \ + '--on-startup=[Run SEC seconds after systemd was first started]:SEC' \ + '--on-unit-active=[Run SEC seconds after the last activation]:SEC' \ + '--on-unit-inactive=[Run SEC seconds after the last deactivation]:SEC' \ + '--on-calendar=[Realtime timer]:SPEC' \ + '--timer-property=[Set timer unit property]:NAME=VALUE' \ + '--wait=[Wait until service stopped again]' \ + '*::command:_command' diff --git a/shell-completion/zsh/_udevadm b/shell-completion/zsh/_udevadm index 020759b006..eb133a42a6 100644 --- a/shell-completion/zsh/_udevadm +++ b/shell-completion/zsh/_udevadm @@ -142,7 +142,6 @@ _udevadm_commands(){ fi } - _arguments \ '--debug[Print debug messages to stderr]' \ '--version[Print version number]' \ |