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