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