]>
| Commit | Line | Data |
|---|---|---|
| 1 | #compdef systemctl | |
| 2 | # SPDX-License-Identifier: LGPL-2.1-or-later | |
| 3 | ||
| 4 | (( $+functions[_systemctl_commands] )) || _systemctl_commands() | |
| 5 | { | |
| 6 | local expl i | |
| 7 | ||
| 8 | local -a unit_commands=( | |
| 9 | # Unit Commands | |
| 10 | "list-automounts:List automounts" | |
| 11 | "list-paths:List paths" | |
| 12 | "list-sockets:List sockets" | |
| 13 | "list-timers:List timers" | |
| 14 | "list-units:List units" | |
| 15 | "start:Start (activate) one or more units" | |
| 16 | "stop:Stop (deactivate) one or more units" | |
| 17 | "reload:Reload one or more units" | |
| 18 | "restart:Start or restart one or more units" | |
| 19 | "condrestart:Restart one or more units if active" | |
| 20 | "try-restart:Restart one or more units if active" | |
| 21 | "reload-or-restart:Reload one or more units if possible, otherwise start or restart" | |
| 22 | "force-reload:Reload one or more units if possible, otherwise restart if active" | |
| 23 | "try-reload-or-restart:Reload one or more units if possible, otherwise restart if active" | |
| 24 | "isolate:Start one unit and stop all others" | |
| 25 | "kill:Send signal to processes of a unit" | |
| 26 | "is-active:Check whether units are active" | |
| 27 | "is-failed:Check whether units are failed" | |
| 28 | "status:Show runtime status of one or more units" | |
| 29 | "show:Show properties of one or more units/jobs or the manager" | |
| 30 | "cat:Show the source unit files and drop-ins" | |
| 31 | "set-property:Sets one or more properties of a unit" | |
| 32 | "service-log-level:Get or set the logging threshold for service" | |
| 33 | "service-log-target:Get or set the logging target for service" | |
| 34 | "help:Show documentation for specified units" | |
| 35 | "reset-failed:Reset failed state for all, one, or more units" | |
| 36 | "list-dependencies:Show unit dependency tree" | |
| 37 | "clean:Remove configuration, state, cache, logs or runtime data of units" | |
| 38 | "freeze:Freeze one or more units specified on the command line using cgroup freezer" | |
| 39 | "thaw:Thaw (unfreeze) one or more units specified on the command line." | |
| 40 | "bind:Bind mount a path from the host into a unit's namespace" | |
| 41 | "mount-image:Mount an image from the host into a unit's namespace" | |
| 42 | "whoami:Determines as part of which unit the command is being invoked" | |
| 43 | ) | |
| 44 | ||
| 45 | local -a machine_commands=( | |
| 46 | # Machine Commands | |
| 47 | "list-machines:List the host and all running local containers" | |
| 48 | ) | |
| 49 | ||
| 50 | local -a unit_file_commands=( | |
| 51 | # Unit File Commands | |
| 52 | "list-unit-files:List installed unit files" | |
| 53 | "enable:Enable one or more unit files" | |
| 54 | "disable:Disable one or more unit files" | |
| 55 | "reenable:Reenable one or more unit files" | |
| 56 | "preset:Enable/disable one or more unit files based on preset configuration" | |
| 57 | "preset-all:Enable/disable all unit files based on preset configuration" | |
| 58 | "is-enabled:Check whether unit files are enabled" | |
| 59 | "mask:Mask one or more units" | |
| 60 | "unmask:Unmask one or more units" | |
| 61 | "link:Link one or more units files into the search path" | |
| 62 | "revert:Revert unit files to their vendor versions" | |
| 63 | "add-wants:Add Wants= dependencies to a unit" | |
| 64 | "add-requires:Add Requires= dependencies to a unit" | |
| 65 | "set-default:Set the default target" | |
| 66 | "get-default:Query the default target" | |
| 67 | "edit:Edit one or more unit files" | |
| 68 | ) | |
| 69 | ||
| 70 | local -a job_commands=( | |
| 71 | # Job Commands | |
| 72 | "list-jobs:List jobs" | |
| 73 | "cancel:Cancel all, one, or more jobs" | |
| 74 | ) | |
| 75 | ||
| 76 | local -a environment_commands=( | |
| 77 | # Environment Commands | |
| 78 | "show-environment:Dump environment" | |
| 79 | "set-environment:Set one or more environment variables" | |
| 80 | "unset-environment:Unset one or more environment variables" | |
| 81 | "import-environment:Import environment variables set on the client" | |
| 82 | ) | |
| 83 | ||
| 84 | local -a manager_state_commands=( | |
| 85 | # Manager State Commands | |
| 86 | "daemon-reload:Reload systemd manager configuration" | |
| 87 | "daemon-reexec:Reexecute systemd manager" | |
| 88 | "log-level:Get or set the log level" | |
| 89 | "log-target:Get or set the log target" | |
| 90 | "service-watchdogs:Get or set the state of software watchdogs" | |
| 91 | ) | |
| 92 | ||
| 93 | local -a system_commands=( | |
| 94 | # System Commands | |
| 95 | "is-system-running:Query overall status of the system" | |
| 96 | "default:Enter system default mode" | |
| 97 | "rescue:Enter system rescue mode" | |
| 98 | "emergency:Enter system emergency mode" | |
| 99 | "halt:Shut down and halt the system" | |
| 100 | "suspend:Suspend the system" | |
| 101 | "poweroff:Shut down and power-off the system" | |
| 102 | "reboot:Shut down and reboot the system" | |
| 103 | "soft-reboot:Shut down and reboot the userspace" | |
| 104 | "kexec:Shut down and reboot the system with kexec" | |
| 105 | "exit:Ask for user instance termination" | |
| 106 | "switch-root:Change root directory" | |
| 107 | "hibernate:Hibernate the system" | |
| 108 | "hybrid-sleep:Hibernate and suspend the system" | |
| 109 | "suspend-then-hibernate:Suspend the system for a period of time, and then hibernate it" | |
| 110 | "sleep:Put the system to sleep" | |
| 111 | ) | |
| 112 | ||
| 113 | local -a groups=( unit machine unit_file job environment manager_state system ) | |
| 114 | local -a _systemctl_cmds | |
| 115 | for i in $groups; do | |
| 116 | _systemctl_cmds+=( "${(@P)${:-"${i}_commands"}}" ) | |
| 117 | done | |
| 118 | ||
| 119 | if (( CURRENT == 1 )); then | |
| 120 | _tags ${^groups//_/-}-commands | |
| 121 | while _tags; do | |
| 122 | for i in $groups; do | |
| 123 | if _requested ${i//_/-}-commands; then | |
| 124 | _describe -t ${i//_/-}-commands "${i//_/ } command" ${i}_commands && | |
| 125 | ret=0 | |
| 126 | fi | |
| 127 | done | |
| 128 | done | |
| 129 | else | |
| 130 | local curcontext="$curcontext" | |
| 131 | ||
| 132 | cmd="${${_systemctl_cmds[(r)$words[1]:*]%%:*}}" | |
| 133 | # Deal with any aliases | |
| 134 | case $cmd in | |
| 135 | condrestart) cmd="try-restart";; | |
| 136 | force-reload) cmd="try-reload-or-restart";; | |
| 137 | esac | |
| 138 | ||
| 139 | if (( $#cmd )); then | |
| 140 | curcontext="${curcontext%:*:*}:systemctl-${cmd}:" | |
| 141 | ||
| 142 | local update_policy | |
| 143 | zstyle -s ":completion:${curcontext}:" cache-policy update_policy | |
| 144 | if [[ -z "$update_policy" ]]; then | |
| 145 | zstyle ":completion:${curcontext}:" cache-policy _systemctl_caching_policy | |
| 146 | fi | |
| 147 | ||
| 148 | _call_function ret _systemctl_$cmd || _message 'no more arguments' | |
| 149 | else | |
| 150 | _message "unknown systemctl command: $words[1]" | |
| 151 | fi | |
| 152 | return ret | |
| 153 | fi | |
| 154 | } | |
| 155 | ||
| 156 | # @todo _systemd-run has a helper with the same name, so we must redefine | |
| 157 | __systemctl() | |
| 158 | { | |
| 159 | command systemctl $_sys_service_mgr --full --legend=no --no-pager --plain "$@" 2>/dev/null | |
| 160 | } | |
| 161 | ||
| 162 | ||
| 163 | # Fills the unit list | |
| 164 | (( $+functions[_systemctl_all_units] )) || | |
| 165 | _systemctl_all_units() | |
| 166 | { | |
| 167 | if _cache_invalid SYS_ALL_UNITS$_sys_service_mgr || ! _retrieve_cache SYS_ALL_UNITS$_sys_service_mgr | |
| 168 | then | |
| 169 | _sys_all_units=( ${${(f)"$(__systemctl list-units --all)"}%% *} ) | |
| 170 | _store_cache SYS_ALL_UNITS$_sys_service_mgr _sys_all_units | |
| 171 | fi | |
| 172 | } | |
| 173 | ||
| 174 | # Fills the unit list including all file units | |
| 175 | (( $+functions[_systemctl_really_all_units] )) || | |
| 176 | _systemctl_really_all_units() | |
| 177 | { | |
| 178 | local -a all_unit_files | |
| 179 | local -a really_all_units | |
| 180 | if _cache_invalid SYS_REALLY_ALL_UNITS$_sys_service_mgr || ! _retrieve_cache SYS_REALLY_ALL_UNITS$_sys_service_mgr | |
| 181 | then | |
| 182 | all_unit_files=( ${${(f)"$(__systemctl list-unit-files)"}%% *} ) | |
| 183 | _systemctl_all_units | |
| 184 | really_all_units=($_sys_all_units $all_unit_files) | |
| 185 | _sys_really_all_units=(${(u)really_all_units}) | |
| 186 | _store_cache SYS_REALLY_ALL_UNITS$_sys_service_mgr _sys_really_all_units | |
| 187 | fi | |
| 188 | } | |
| 189 | ||
| 190 | (( $+functions[_filter_units_by_property] )) || | |
| 191 | _filter_units_by_property() { | |
| 192 | local property=$1 value=$2; shift 2 | |
| 193 | local -a units; units=("${(q-)@}") | |
| 194 | local -A props | |
| 195 | props=(${(f)"$(_call_program units "$service $_sys_service_mgr show --no-pager --property=\"Id,$property\" -- ${units} 2>/dev/null")"}) | |
| 196 | echo -E - "${(@)${(k@)props[(Re)$property=$value]}#Id=}" | |
| 197 | } | |
| 198 | ||
| 199 | (( $+functions[_systemctl_get_non_template_names] )) || | |
| 200 | _systemctl_get_non_template_names() { | |
| 201 | _systemctl_really_all_units | |
| 202 | print -r - ${_sys_really_all_units:#*@.*} | |
| 203 | } | |
| 204 | ||
| 205 | (( $+functions[_systemctl_get_template_names] )) || | |
| 206 | _systemctl_get_template_names() { | |
| 207 | local pathkind=systemd-search-${_sys_service_mgr##*--}-unit | |
| 208 | print -r - ${(s-:-)^$(_call_program $pathkind systemd-path $pathkind)}/*@.(${(~j.|.)$(__systemctl --type=help)})(N:t:r) | |
| 209 | } | |
| 210 | ||
| 211 | (( $+functions[_systemctl_active_units] )) || | |
| 212 | _systemctl_active_units() { | |
| 213 | local pattern | |
| 214 | if zstyle -T ":completion:$curcontext" use-pattern; then | |
| 215 | pattern="$PREFIX*$SUFFIX" | |
| 216 | fi | |
| 217 | _sys_active_units=( ${${(f)"$(__systemctl list-units $pattern)"}%% *} ) | |
| 218 | } | |
| 219 | ||
| 220 | (( $+functions[_systemctl_startable_units] )) || | |
| 221 | _systemctl_startable_units(){ | |
| 222 | local pattern | |
| 223 | if zstyle -T ":completion:$curcontext" use-pattern; then | |
| 224 | pattern="$PREFIX*$SUFFIX" | |
| 225 | fi | |
| 226 | _sys_startable_units=( $( _filter_units_by_property ActiveState inactive $( | |
| 227 | _filter_units_by_property CanStart yes ${${${(f)"$( | |
| 228 | __systemctl list-unit-files --state enabled,enabled-runtime,linked,linked-runtime,static,indirect,disabled,generated,transient $pattern | |
| 229 | __systemctl list-units --state inactive,failed $pattern | |
| 230 | )"}:#*@.*}%%[[:space:]]*} | |
| 231 | )) ) | |
| 232 | } | |
| 233 | ||
| 234 | (( $+functions[_systemctl_restartable_units] )) || | |
| 235 | _systemctl_restartable_units(){ | |
| 236 | local pattern | |
| 237 | if zstyle -T ":completion:$curcontext" use-pattern; then | |
| 238 | pattern="$PREFIX*$SUFFIX" | |
| 239 | fi | |
| 240 | _sys_restartable_units=( $( _filter_units_by_property CanStart yes ${${${(f)"$( | |
| 241 | __systemctl list-unit-files --state enabled,disabled,static $pattern | |
| 242 | __systemctl list-units $pattern | |
| 243 | )"}:#*@.*}%%[[:space:]]*} ) ) | |
| 244 | } | |
| 245 | ||
| 246 | (( $+functions[_systemctl_failed_units] )) || | |
| 247 | _systemctl_failed_units() {_sys_failed_units=( ${${(f)"$(__systemctl list-units --state=failed)"}%% *} ) } | |
| 248 | ||
| 249 | (( $+functions[_systemctl_unit_state] )) || | |
| 250 | _systemctl_unit_state() { | |
| 251 | setopt localoptions extendedglob | |
| 252 | local pattern | |
| 253 | if zstyle -T ":completion:$curcontext" use-pattern; then | |
| 254 | pattern="$PREFIX*$SUFFIX" | |
| 255 | fi | |
| 256 | typeset -gA _sys_unit_state | |
| 257 | _sys_unit_state=( ${=${${(f)"$(__systemctl list-unit-files $pattern)"}%%[[:space:]]#}% *} ) | |
| 258 | } | |
| 259 | ||
| 260 | local fun | |
| 261 | # Completion functions for ALL_UNITS | |
| 262 | for fun in cat mask ; do | |
| 263 | (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() | |
| 264 | { | |
| 265 | _systemctl_really_all_units | |
| 266 | _wanted systemd-units expl unit \ | |
| 267 | compadd "$@" -a - _sys_really_all_units | |
| 268 | } | |
| 269 | done | |
| 270 | ||
| 271 | # Completion functions for NONTEMPLATE_UNITS | |
| 272 | for fun in is-active is-failed is-enabled status show preset help list-dependencies edit revert add-wants add-requires set-property; do | |
| 273 | (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() | |
| 274 | { | |
| 275 | _wanted systemd-units expl unit \ | |
| 276 | compadd "$@" - $(_systemctl_get_non_template_names) | |
| 277 | } | |
| 278 | done | |
| 279 | ||
| 280 | # Completion functions for ENABLED_UNITS | |
| 281 | (( $+functions[_systemctl_disable] )) || _systemctl_disable() | |
| 282 | { | |
| 283 | local _sys_unit_state; _systemctl_unit_state | |
| 284 | _wanted systemd-units expl 'enabled unit' \ | |
| 285 | compadd "$@" - ${(k)_sys_unit_state[(R)enabled]} | |
| 286 | } | |
| 287 | ||
| 288 | (( $+functions[_systemctl_reenable] )) || _systemctl_reenable() | |
| 289 | { | |
| 290 | local _sys_unit_state; _systemctl_unit_state | |
| 291 | _wanted systemd-units expl 'enabled/disabled unit' \ | |
| 292 | compadd "$@" - ${(k)_sys_unit_state[(R)(enabled|disabled)]} $(_systemctl_get_template_names) | |
| 293 | } | |
| 294 | ||
| 295 | # Completion functions for DISABLED_UNITS | |
| 296 | (( $+functions[_systemctl_enable] )) || _systemctl_enable() | |
| 297 | { | |
| 298 | local _sys_unit_state; _systemctl_unit_state | |
| 299 | _wanted systemd-units expl 'disabled unit' \ | |
| 300 | compadd "$@" - ${(k)_sys_unit_state[(R)disabled]} $(_systemctl_get_template_names) | |
| 301 | } | |
| 302 | ||
| 303 | # Completion functions for FAILED_UNITS | |
| 304 | (( $+functions[_systemctl_reset-failed] )) || _systemctl_reset-failed() | |
| 305 | { | |
| 306 | local _sys_failed_units; _systemctl_failed_units | |
| 307 | _wanted systemd-units expl 'failed unit' \ | |
| 308 | compadd "$@" -a - _sys_failed_units || _message "no failed unit found" | |
| 309 | } | |
| 310 | ||
| 311 | # Completion functions for STARTABLE_UNITS | |
| 312 | (( $+functions[_systemctl_start] )) || _systemctl_start() | |
| 313 | { | |
| 314 | local _sys_startable_units; _systemctl_startable_units | |
| 315 | _wanted systemd-units expl 'startable unit' \ | |
| 316 | compadd "$@" - ${_sys_startable_units[*]} | |
| 317 | } | |
| 318 | ||
| 319 | # Completion functions for STOPPABLE_UNITS | |
| 320 | for fun in stop condstop kill try-restart condrestart freeze thaw; do | |
| 321 | (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() | |
| 322 | { | |
| 323 | local _sys_active_units; _systemctl_active_units | |
| 324 | _wanted systemd-units expl 'stoppable unit' \ | |
| 325 | compadd "$@" - $( _filter_units_by_property CanStop yes \ | |
| 326 | ${_sys_active_units[*]} ) | |
| 327 | } | |
| 328 | done | |
| 329 | ||
| 330 | (( $+functions[_systemctl_service-log-level] )) || | |
| 331 | _systemctl_service-log-level() { | |
| 332 | local -a log_levels=( emerg alert crit err warning notice info debug ) | |
| 333 | local _sys_active_units; _systemctl_active_units | |
| 334 | if (( CURRENT == 2 )); then | |
| 335 | _wanted systemd-units expl 'active unit' \ | |
| 336 | compadd "$@" -a - _sys_active_units || _message "no units found" | |
| 337 | else | |
| 338 | compadd "$@" -a - log_levels | |
| 339 | fi | |
| 340 | } | |
| 341 | ||
| 342 | (( $+functions[_systemctl_service-log-target] )) || | |
| 343 | _systemctl_service-log-target() { | |
| 344 | local -a log_targets=( console kmsg journal syslog null auto ) | |
| 345 | local _sys_active_units; _systemctl_active_units | |
| 346 | if (( CURRENT == 2 )); then | |
| 347 | _wanted systemd-units expl 'active unit' \ | |
| 348 | compadd "$@" -a - _sys_active_units || _message "no units found" | |
| 349 | else | |
| 350 | compadd "$@" -a - log_targets | |
| 351 | fi | |
| 352 | } | |
| 353 | ||
| 354 | # Completion functions for ISOLATABLE_UNITS | |
| 355 | (( $+functions[_systemctl_isolate] )) || _systemctl_isolate() | |
| 356 | { | |
| 357 | _systemctl_all_units | |
| 358 | _wanted systemd-units expl 'isolatable unit' \ | |
| 359 | compadd "$@" - $( _filter_units_by_property AllowIsolate yes \ | |
| 360 | ${_sys_all_units[*]} ) | |
| 361 | } | |
| 362 | ||
| 363 | # Completion functions for RELOADABLE_UNITS | |
| 364 | for fun in reload try-reload-or-restart force-reload ; do | |
| 365 | (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() | |
| 366 | { | |
| 367 | local _sys_active_units; _systemctl_active_units | |
| 368 | _wanted systemd-units expl 'reloadable unit' \ | |
| 369 | compadd "$@" - $( _filter_units_by_property CanReload yes \ | |
| 370 | ${_sys_active_units[*]} ) | |
| 371 | } | |
| 372 | done | |
| 373 | ||
| 374 | # Completion functions for RESTARTABLE_UNITS | |
| 375 | for fun in restart reload-or-restart ; do | |
| 376 | (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() | |
| 377 | { | |
| 378 | local _sys_restartable_units; _systemctl_restartable_units | |
| 379 | _wanted systemd-units expl 'restartable unit' \ | |
| 380 | compadd "$@" - ${_sys_restartable_units[*]} | |
| 381 | } | |
| 382 | done | |
| 383 | ||
| 384 | # Completion functions for MASKED_UNITS | |
| 385 | (( $+functions[_systemctl_unmask] )) || _systemctl_unmask() | |
| 386 | { | |
| 387 | local _sys_unit_state; _systemctl_unit_state | |
| 388 | _wanted systemd-units expl 'masked unit' \ | |
| 389 | compadd "$@" - ${(k)_sys_unit_state[(R)masked]} || _message "no masked units found" | |
| 390 | } | |
| 391 | ||
| 392 | # Completion functions for JOBS | |
| 393 | (( $+functions[_systemctl_cancel] )) || _systemctl_cancel() | |
| 394 | { | |
| 395 | _wanted systemd-jobs expl job \ | |
| 396 | compadd "$@" - ${${(f)"$(__systemctl list-jobs)"}%% *} || | |
| 397 | _message "no jobs found" | |
| 398 | } | |
| 399 | ||
| 400 | # Completion functions for TARGETS | |
| 401 | (( $+functions[_systemctl_set-default] )) || _systemctl_set-default() | |
| 402 | { | |
| 403 | _wanted systemd-targets expl target \ | |
| 404 | compadd "$@" - ${${(f)"$(__systemctl list-unit-files --type target --all)"}%% *} || | |
| 405 | _message "no targets found" | |
| 406 | } | |
| 407 | ||
| 408 | # Completion functions for ENVS | |
| 409 | for fun in set-environment unset-environment ; do | |
| 410 | (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() | |
| 411 | { | |
| 412 | local fun=$0 ; fun=${fun##_systemctl_} | |
| 413 | local suf | |
| 414 | if [[ "${fun}" = "set-environment" ]]; then | |
| 415 | suf='-S=' | |
| 416 | fi | |
| 417 | _wanted systemd-environment expl 'environment variable' \ | |
| 418 | compadd "$@" ${suf} - ${${(f)"$(systemctl "$_sys_service_mgr" show-environment)"}%%=*} | |
| 419 | } | |
| 420 | done | |
| 421 | ||
| 422 | (( $+functions[_systemctl_import-environment] )) || _systemctl_import-environment() | |
| 423 | { | |
| 424 | _parameters | |
| 425 | } | |
| 426 | ||
| 427 | (( $+functions[_systemctl_link] )) || _systemctl_link() { | |
| 428 | _sd_unit_files | |
| 429 | } | |
| 430 | ||
| 431 | (( $+functions[_systemctl_switch-root] )) || _systemctl_switch-root() { | |
| 432 | _files | |
| 433 | } | |
| 434 | ||
| 435 | (( $+functions[_systemctl_bind] )) || _systemctl_bind() { | |
| 436 | _files | |
| 437 | } | |
| 438 | ||
| 439 | (( $+functions[_systemctl_mount-image] )) || _systemctl_mount-image() { | |
| 440 | _files | |
| 441 | } | |
| 442 | ||
| 443 | # no systemctl completion for: | |
| 444 | # [STANDALONE]='daemon-reexec daemon-reload default | |
| 445 | # emergency exit halt kexec list-jobs list-units | |
| 446 | # list-unit-files poweroff reboot rescue show-environment' | |
| 447 | ||
| 448 | (( $+functions[_systemctl_caching_policy] )) || | |
| 449 | _systemctl_caching_policy() | |
| 450 | { | |
| 451 | # rebuild if cache is more than a day old | |
| 452 | [[ -n $1(#qNmd+1) ]] && return 0 | |
| 453 | ||
| 454 | local pathkind=systemd-search-${1##*--}-unit | |
| 455 | for dir in ${(s-:-)^$(_call_program $pathkind systemd-path $pathkind)}; do | |
| 456 | [[ $dir -nt $1 ]] && return 0 | |
| 457 | done | |
| 458 | ||
| 459 | return 1 | |
| 460 | } | |
| 461 | ||
| 462 | (( $+functions[_systemctl_unit_states] )) || | |
| 463 | _systemctl_unit_states() { | |
| 464 | local -a _states | |
| 465 | _states=("${(fo)$(__systemctl --state=help)}") | |
| 466 | _values -s , "${_states[@]}" | |
| 467 | } | |
| 468 | ||
| 469 | (( $+functions[_systemctl_unit_types] )) || | |
| 470 | _systemctl_unit_types() { | |
| 471 | local -a _types | |
| 472 | _types=("${(fo)$(__systemctl -t help)}") | |
| 473 | _values -s , "${_types[@]}" | |
| 474 | } | |
| 475 | ||
| 476 | (( $+functions[_systemctl_unit_properties] )) || | |
| 477 | _systemctl_unit_properties() { | |
| 478 | local -a _sys_all_properties=( ${(f)"$({{LIBEXECDIR}}/systemd --no-pager --dump-bus-properties 2>/dev/null)"} ) | |
| 479 | _wanted systemd-unit-properties expl 'unit property' \ | |
| 480 | _values -s , "${_sys_all_properties[@]}" | |
| 481 | } | |
| 482 | ||
| 483 | (( $+functions[_systemctl_job_modes] )) || | |
| 484 | _systemctl_job_modes() { | |
| 485 | local -a _modes | |
| 486 | _modes=(fail replace replace-irreversibly isolate ignore-dependencies ignore-requirements flush) | |
| 487 | _values -s , "${_modes[@]}" | |
| 488 | } | |
| 489 | ||
| 490 | (( $+functions[_systemctl_timestamp] )) || | |
| 491 | _systemctl_timestamp() { | |
| 492 | local -a _styles | |
| 493 | _styles=(help pretty us µs utc us+utc µs+utc) | |
| 494 | _values -s , "${_styles[@]}" | |
| 495 | } | |
| 496 | ||
| 497 | (( $+functions[_systemctl_check_inhibitors] )) || | |
| 498 | _systemctl_check_inhibitors() { | |
| 499 | local -a _modes | |
| 500 | _modes=(auto yes no) | |
| 501 | _values -s , "${_modes[@]}" | |
| 502 | } | |
| 503 | ||
| 504 | # Build arguments for "systemctl" to be used in completion. | |
| 505 | # Use the last mode, or --system (they are exclusive and the last one is used). | |
| 506 | local _sys_service_mgr=${words[(R)(--user|--system)]:---system} | |
| 507 | _arguments -s \ | |
| 508 | '(- *)'{-h,--help}'[Show help]' \ | |
| 509 | '(- *)--version[Show package version]' \ | |
| 510 | '(-t --type)'{-t+,--type=}'[List only units of a particular type]:unit type:_systemctl_unit_types' \ | |
| 511 | '--state=[Display units in the specified state]:unit state:_systemctl_unit_states' \ | |
| 512 | '--job-mode=[Specify how to deal with other jobs]:mode:_systemctl_job_modes' \ | |
| 513 | '(-p --property)'{-p+,--property=}'[Show only properties by specific name]:unit property:_systemctl_unit_properties' \ | |
| 514 | '(-a --all)'{-a,--all}'[Show all units/properties, including dead/empty ones]' \ | |
| 515 | '--reverse[Show reverse dependencies]' \ | |
| 516 | '--after[Show units ordered after]' \ | |
| 517 | '--before[Show units ordered before]' \ | |
| 518 | '(-l --full)'{-l,--full}"[Don't ellipsize unit names on output]" \ | |
| 519 | '--show-types[When showing sockets, show socket type]' \ | |
| 520 | '--check-inhibitors[Specify if inhibitors should be checked]:mode:_systemctl_check_inhibitors' \ | |
| 521 | '(-q --quiet)'{-q,--quiet}'[Suppress output]' \ | |
| 522 | '--no-warn[Suppress several warnings shown by default]' \ | |
| 523 | '--no-block[Do not wait until operation finished]' \ | |
| 524 | '--legend=no[Do not print a legend, i.e. the column headers and the footer with hints]' \ | |
| 525 | '--no-pager[Do not pipe output into a pager]' \ | |
| 526 | '--system[Connect to system manager]' \ | |
| 527 | '--user[Connect to user service manager]' \ | |
| 528 | "--no-wall[Don't send wall message before halt/power-off/reboot]" \ | |
| 529 | '--global[Enable/disable/mask default user unit files globally]' \ | |
| 530 | "--no-reload[When enabling/disabling unit files, don't reload daemon configuration]" \ | |
| 531 | '--no-ask-password[Do not ask for system passwords]' \ | |
| 532 | '--kill-whom=[Whom to send signal to]:killwhom:(main control all)' \ | |
| 533 | '(-s --signal)'{-s+,--signal=}'[Which signal to send]:signal:_signals' \ | |
| 534 | '(-f --force)'{-f,--force}'[When enabling unit files, override existing symlinks. When shutting down, execute action immediately]' \ | |
| 535 | '--root=[Enable/disable/mask unit files in the specified root directory]:directory:_directories' \ | |
| 536 | '--runtime[Enable/disable/mask unit files only temporarily until next reboot]' \ | |
| 537 | '(-H --host)'{-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \ | |
| 538 | '(-P --privileged)'{-P,--privileged}'[Acquire privileges before execution]' \ | |
| 539 | '(-n --lines)'{-n+,--lines=}'[Journal entries to show]:number of entries' \ | |
| 540 | '(-o --output)'{-o+,--output=}'[Change journal output mode]:modes:_sd_outputmodes' \ | |
| 541 | '--firmware-setup[Tell the firmware to show the setup menu on next boot]' \ | |
| 542 | '--plain[When used with list-dependencies, print output as a list]' \ | |
| 543 | '--failed[Show failed units]' \ | |
| 544 | '--timestamp=[Change format of printed timestamps]:style:_systemctl_timestamp' \ | |
| 545 | '*::systemctl command:_systemctl_commands' |