diff options
| author | Peter Stephenson <pws@users.sourceforge.net> | 2011-10-24 11:32:41 +0000 |
|---|---|---|
| committer | Peter Stephenson <pws@users.sourceforge.net> | 2011-10-24 11:32:41 +0000 |
| commit | e5f1efa5a23213fdeb64907fbb5fc8db37aa5e0a (patch) | |
| tree | 47a6ff67aa1d976c085960a5834b9458de43ed22 /Completion/Unix/Command | |
| parent | 29838: metafy/unmetafy strings for PCRE matching (UTF-8 fixes) (diff) | |
| download | zsh-e5f1efa5a23213fdeb64907fbb5fc8db37aa5e0a.tar zsh-e5f1efa5a23213fdeb64907fbb5fc8db37aa5e0a.tar.gz zsh-e5f1efa5a23213fdeb64907fbb5fc8db37aa5e0a.tar.bz2 zsh-e5f1efa5a23213fdeb64907fbb5fc8db37aa5e0a.tar.lz zsh-e5f1efa5a23213fdeb64907fbb5fc8db37aa5e0a.tar.xz zsh-e5f1efa5a23213fdeb64907fbb5fc8db37aa5e0a.tar.zst zsh-e5f1efa5a23213fdeb64907fbb5fc8db37aa5e0a.zip | |
Foudil Brétel: 29842: major update to systemctl completion
Diffstat (limited to 'Completion/Unix/Command')
| -rw-r--r-- | Completion/Unix/Command/_systemctl | 339 |
1 files changed, 264 insertions, 75 deletions
diff --git a/Completion/Unix/Command/_systemctl b/Completion/Unix/Command/_systemctl index 5dd35db7a..801a8e060 100644 --- a/Completion/Unix/Command/_systemctl +++ b/Completion/Unix/Command/_systemctl @@ -1,102 +1,291 @@ #compdef systemctl -# Completion for systemd's systemctl -# Version 1.0 ARF 3 August 2011 +# Copyright (c) 2011 Foudil Brétel <foudil.newbie+zshsystemctl@gmail.com> +# +# This file is released under the GPLv3. +# +# inspired from _yum and systemctl-bash-completion.sh (shipped with systemctl) +# +# TODO: enable options after commands. Ex: systemctl list-units --all --full -# list the unit completions. -_systemd_units(){ - local -a units - local expl - units=(${(f)"$( systemctl --full list-units | sed -e 's/ .*//' )"}) - _wanted keys expl 'units' compadd "$units[@]" -} - -# list the job completions. -_systemd_jobs(){ - local -a jobs - local expl - jobs=(${(f)"$( systemctl --full list-jobs | sed -e 's/ .*//' )"}) - _wanted keys expl 'jobs' compadd "$jobs[@]" -} - -# list the snapshot completions. -_systemd_snapshots(){ - local -a ss - local expl - ss=(${(f)"$( - systemctl dump | sed -n -e 's/^-> Unit \(.*\.snapshot\):/\1/p' - )"}) - _wanted keys expl 'snapshots' compadd "$ss[@]" -} - -_systemctl(){ - local -a _systemctl_cmds +# Main dispatcher +_systemctl() +{ + local curcontext="$curcontext" state lstate line - # Determine the sub commands - #$(systemctl --help | sed -n -e 's/^ \([a-z]\)/\1/p' | sed -e 's/ .*//') - _systemctl_cmds=( - list-units start stop reload restart try-restart reload-or- - restart reload-or-try-restart isolate kill is-active status show - reset-failed enable disable is-enabled load list-jobs cancel - monitor dump dot snapshot delete daemon-reload daemon-reexec show- - environment set-environment unset-environment default rescue - emergency halt poweroff reboot kexec exit - ) - - local curcontext="$curcontext" state line expl - typeset -A opt_args - - # Initial flags - _arguments -A '-*' \ - '--help[Show help]' \ + # -s for aggregated options like -aP + _arguments -s \ + {-h,--help}'[Show help]' \ '--version[Show package version]' \ - '(-a,--all)'{-a,--all}'[Show all units/properties, including dead/empty ones]' \ - '--full[Dont ellipsize unit names on output]' \ + {-t,--type=}'[List only units of a particular type]:unit type:(automount device mount path service snapshot socket swap target timer)' \ + \*{-p,--property=}'[Show only properties by specific name]:unit property:' \ + {-a,--all}'[Show all units/properties, including dead/empty ones]' \ '--failed[Show only failed units]' \ + "--full[Don't ellipsize unit names on output]" \ '--fail[When queueing a new job, fail if conflicting jobs are pending]' \ - '--ignore-dependencies[ignore dependencies]' \ - '(-p,--privileged)'{-p,--privileged}'[Acquire privileges before execution]' \ - '(-q,--quiet)'{-q,--quiet}'[Suppress output]' \ + '--ignore-dependencies[When queueing a new job, ignore all its dependencies]' \ + '--kill-mode=[How to send signal]:killmode:(control-group process)' \ + '--kill-who=[Who to send signal to]:killwho:(main control all)' \ + {-s,--signal=}'[Which signal to send]:signal:_signals' \ + {-H,--host=}'[Show information for remote host]:userathost:_hosts_or_user_at_host' \ + {-P,--privileged}'[Acquire privileges before execution]' \ + {-q,--quiet}'[Suppress output]' \ '--no-block[Do not wait until operation finished]' \ - '--no-wall[Dont send wall message before halt/power-off/reboot]' \ - '--no-reload[dont reload daemon configuration]' \ - '--no-pager[Do use pager]' \ + "--no-wall[Don't send wall message before halt/power-off/reboot]" \ + "--no-reload[When enabling/disabling unit files, don't reload daemon configuration]" \ + '--no-pager[Do not pipe output into a pager]' \ '--no-ask-password[Do not ask for system passwords]' \ '--order[When generating graph for dot, show only order]' \ '--require[When generating graph for dot, show only requirement]' \ '--system[Connect to system manager]' \ '--user[Connect to user service manager]' \ '--global[Enable/disable unit files globally]' \ - '(-f,--force)'{-f,--force}'[When enabling unit files, override existing symlinks. When shutting down, execute action immediately]' \ + {-f,--force}'[When enabling unit files, override existing symlinks. When shutting down, execute action immediately]' \ '--defaults[When disabling unit files, remove default symlinks only]' \ - '*::command:->subcmd' && return 0 + '*::systemctl command:_systemctl_command' +} + +_hosts_or_user_at_host() +{ + _alternative \ + 'users-hosts:: _user_at_host' \ + 'hosts:: _hosts' +} + +(( $+functions[_systemctl_command] )) || _systemctl_command() +{ + local -a _systemctl_cmds + _systemctl_cmds=( + "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" + "try-restart:Restart one or more units if active" + "reload-or-restart:Reload one or more units is possible, otherwise start or restart" + "reload-or-try-restart:Reload one or more units is 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" + "status:Show runtime status of one or more units" |
