1 #compdef systemctl loginctl journalctl hostnamectl localectl timedatectl systemd-coredumpctl udevadm systemd-analyze systemd-cat systemd-ask-password systemd-cgls systemd-cgtop systemd-delta systemd-detect-virt systemd-inhibit systemd-machine-id-setup systemd-notify systemd-nspawn systemd-tmpfiles systemd-tty-ask-password-agent
5 local curcontext="$curcontext" state lstate line
8 # -s for aggregated options like -aP
10 {-h,--help}'[Show help]' \
11 '--version[Show package version]' \
12 {-t,--type=}'[List only units of a particular type]:unit type:(automount device mount path service snapshot socket swap target timer)' \
13 \*{-p,--property=}'[Show only properties by specific name]:unit property' \
14 {-a,--all}'[Show all units/properties, including dead/empty ones]' \
15 '--reverse[Show reverse dependencies]' \
16 '--after[Show units ordered after]' \
17 '--before[Show units ordered before]' \
18 '--failed[Show only failed units]' \
19 "--full[Don't ellipsize unit names on output]" \
20 '--fail[When queueing a new job, fail if conflicting jobs are pending]' \
21 '--ignore-dependencies[When queueing a new job, ignore all its dependencies]' \
22 '--kill-who=[Who to send signal to]:killwho:(main control all)' \
23 {-s,--signal=}'[Which signal to send]:signal:_signals' \
24 {-H,--host=}'[Show information for remote host]:userathost:_hosts_or_user_at_host' \
25 {-P,--privileged}'[Acquire privileges before execution]' \
26 {-q,--quiet}'[Suppress output]' \
27 '--no-block[Do not wait until operation finished]' \
28 "--no-wall[Don't send wall message before halt/power-off/reboot]" \
29 "--no-reload[When enabling/disabling unit files, don't reload daemon configuration]" \
30 '--no-legend[Do not print a legend, i.e. the column headers and the footer with hints]' \
31 '--no-pager[Do not pipe output into a pager]' \
32 '--no-ask-password[Do not ask for system passwords]' \
33 '--system[Connect to system manager]' \
34 '--user[Connect to user service manager]' \
35 '--global[Enable/disable unit files globally]' \
36 {-f,--force}'[When enabling unit files, override existing symlinks. When shutting down, execute action immediately]' \
37 '--root=[Enable unit files in the specified root directory]:directory:_directories' \
38 '--runtime[Enable unit files only temporarily until next reboot]' \
39 {-n,--lines=}'[Journal entries to show]:number of entries' \
40 {-o,--output=}'[Change journal output mode]:modes:_outputmodes' \
41 '*::systemctl command:_systemctl_command'
45 {-h,--help}'[Show help]' \
46 '--version[Show package version]' \
47 \*{-p,--property=}'[Show only properties by this name]:unit property' \
48 {-a,--all}'[Show all properties, including empty ones]' \
49 '--kill-who=[Who to send signal to]:killwho:(main control all)' \
50 {-s,--signal=}'[Which signal to send]:signal:_signals' \
51 '--no-ask-password[Do not ask for system passwords]' \
52 {-H,--host=}'[Show information for remote host]:userathost:_hosts_or_user_at_host' \
53 {-P,--privileged}'[Acquire privileges before execution]' \
54 '--no-pager[Do not pipe output into a pager]' \
55 '*::loginctl command:_loginctl_command'
60 {-h,--help}'[Show this help]' \
61 '--version[Show package version]' \
62 '--transient[Only set transient hostname]' \
63 '--static[Only set static hostname]' \
64 '--pretty[Only set pretty hostname]' \
65 '--no-ask-password[Do not prompt for password]' \
66 {-H,--host=}'[Operate on remote host]:userathost:_hosts_or_user_at_host' \
67 '*::hostnamectl commands:_hostnamectl_command'
71 '--since=[Start showing entries newer or of the specified date]:YYYY-MM-DD HH\:MM\:SS' \
72 '--until=[Stop showing entries older or of the specified date]:YYYY-MM-DD HH\:MM\:SS' \
73 {-c,--cursor=}'[Start showing entries from specified cursor]:cursors:_journal_fields __CURSORS' \
74 {-b,--this-boot}'[Show data only from current boot]' \
75 {-u,--unit=}'[Show data only from the specified unit]:units:_journal_fields _SYSTEMD_UNIT' \
76 '--user-unit[Show data only from the specified user session unit]:units:_journal_fields _SYSTEMD_USER_UNIT' \
77 {-p,--priority=}'[Show only messages within the specified priority range]:priority:_journal_fields PRIORITY' \
78 {-f,--follow}'[Follow journal]' \
79 {-n,--lines=}'[Number of journal entries to show]:integer' \
80 '--no-tail[Show all lines, even in follow mode]' \
81 {-o,--output=}'[Change journal output mode]:output modes:_outputmodes' \
82 '--full[Show long fields in full]' \
83 {-a,--all}'[Show all fields, including long and unprintable]' \
84 {-q,--quiet}"[Don't show privilege warning]" \
85 '--no-pager[Do not pipe output into a pager]' \
86 {-m,--merge}'[Show entries from all available journals]' \
87 {-D,--directory=}'[Show journal files from directory]:directories:_directories' \
88 '--interval=[Time interval for changing the FSS sealing key]:time interval' \
89 '--verify-key=[Specify FSS verification key]:FSS key' \
90 {-h,--help}'[Show this help]' \
91 '--version[Show package version]' \
92 '--new-id128[Generate a new 128 Bit ID]' \
93 '--header[Show journal header information]' \
94 '--disk-usage[Show total disk usage]' \
95 {-F,--field=}'[List all values a certain field takes]:Fields:_list_fields' \
96 '--setup-keys[Generate new FSS key pair]' \
97 '--verify[Verify journal file consistency]' \
98 '--list-catalog[List messages in catalog]' \
99 '--update-catalog[Update binary catalog database]' \
100 '*::default: _journal_none'
104 {-h,--help}'[Show this help]' \
105 '--version[Show package version]' \
106 "--no-convert[Don't convert keyboard mappings]" \
107 '--no-pager[Do not pipe output into a pager]' \
108 '--no-ask-password[Do not prompt for password]' \
109 {-H,--host=}'[Operate on remote host]:userathost:_hosts_or_user_at_host' \
110 '*::localectl commands:_localectl_command'
114 {-o,--output=}'[Write output to FILE]:output file:_files' \
115 '--no-pager[Do not pipe output into a pager]' \
116 {-h,--help}'[Show this help]' \
117 '--version[Show package version]' \
118 '*::systemd-coredumpctl commands:_systemd-coredumpctl_command'
123 {-h,--help}'[Show this help]' \
124 '--version[Show package version]' \
125 '--adjust-system-clock[Adjust system clock when changing local RTC mode]' \
126 '--no-pager[Do not pipe output into a pager]' \
127 '--no-ask-password[Do not prompt for password]' \
128 {-H,--host=}'[Operate on remote host]:userathost:_hosts_or_user_at_host' \
129 '*::timedatectl commands:_timedatectl_command'
133 '--debug[Print debug messages to stderr]' \
134 '--version[Print version number]' \
135 '--help[Print help text]' \
136 '*::udevadm commands:_udevadm_command'
140 {-h,--help}'[Show help text.]' \
141 '--user[Shows performance data of user sessions instead of the system manager.]' \
142 '--order[When generating graph for dot, show only order]' \
143 '--require[When generating graph for dot, show only requirement]' \
144 '*::systemd-analyze commands:_systemd_analyze_command'
146 systemd-ask-password)
148 {-h,--help}'[Show this help]' \
149 '--icon=[Icon name]' \
150 '--timeout=[Timeout in sec]' \
151 '--no-tty[Ask question via agent even on TTY]' \
152 '--accept-cached[Accept cached passwords]' \
153 '--multiple[List multiple passwords if available]'
157 {-h,--help}'[Show this help]' \
158 '--version[Show package version.]' \
159 {-t,--identifier=}'[Set syslog identifier.]' \
160 {-p,--priority=}'[Set priority value.]:value:({0..7})' \
161 '--level-prefix=[Control whether level prefix shall be parsed.]:boolean:(1 0)' \
166 {-h,--help}'[Show this help]' \
167 '--version[Show package version]' \
168 '--no-pager[Do not pipe output into a pager]' \
169 {-a,--all}'[Show all groups, including empty]' \
170 '-k[Include kernel threads in output]' \
171 ':cgroups:(cpuset cpu cpuacct memory devices freezer net_cls blkio)'
175 {-h,--help}'[Show this help]' \
176 '--version[Print version and exit]' \
177 '(-c -m -i -t)-p[Order by path]' \
178 '(-c -p -m -i)-t[Order by number of tasks]' \
179 '(-m -p -i -t)-c[Order by CPU load]' \
180 '(-c -p -i -t)-m[Order by memory load]' \
181 '(-c -m -p -t)-i[Order by IO load]' \
182 {-d,--delay=}'[Specify delay]' \
183 {-n,--iterations=}'[Run for N iterations before exiting]' \
184 {-b,--batch}'[Run in batch mode, accepting no input]' \
185 '--depth=[Maximum traversal depth]'
189 {-h,--help}'[Show this help]' \
190 '--version[Show package version]' \
191 '--no-pager[Do not pipe output into a pager]' \
192 '--diff=[Show a diff when overridden files differ]:boolean:(1 0)' \
193 {-t,--type=}'[Only display a selected set of override types]:types:(masked equivalent redirected overridden unchanged)' \
194 ':SUFFIX:(tmpfiles.d sysctl.d systemd/system)'
198 {-h,--help}'[Show this help]' \
199 '--version[Show package version]' \
200 {-c,--container}'[Only detect whether we are run in a container]' \
201 {-v,--vm}'[Only detect whether we are run in a VM]' \
202 {-q,--quiet}"[Don't output anything, just set return value]"
206 {-h,--help}'[Show this help]' \
207 '--version[Show package version]' \
208 '--what=[Operations to inhibit]:options:(shutdown sleep idle handle-power-key handle-suspend-key handle-hibernate-key handle-lid-switch)' \
209 '--who=[A descriptive string who is inhibiting]' \
210 '--why=[A descriptive string why is being inhibited]' \
211 '--mode=[One of block or delay]' \
212 '--list[List active inhibitors]' \
213 '*:commands:_systemd_inhibit_command'
215 systemd-machine-id-setup)
217 {-h,--help}'[Show this help]' \
218 '--version[Show package version]'
222 {-h,--help}'[Show this help]' \
223 '--version[Show package version]' \
224 '--ready[Inform the init system about service start-up completion.]' \
225 '--pid=[Inform the init system about the main PID of the daemon]' \
226 '--status=[Send a free-form status string for the daemon to the init systemd]' \
227 '--booted[Returns 0 if the system was booted up with systemd]' \
228 '--readahead=[Controls disk read-ahead operations]:arguments:(cancel done noreply)'
232 {-h,--help}'[Show this help]' \
233 {--directory=,-D}'[Directory to use as file system root for the namespace container. If omitted the current directory will be used.]:directories:_directories' \
234 {--boot,-b}'[Automatically search for an init binary and invoke it instead of a shell or a user supplied program.]' \
235 {--user=,-u}'[Run the command under specified user, create home directory and cd into it.]' \
236 '--uuid=[Set the specified uuid for the container.]' \
237 {--controllers=,-C}'[Makes the container appear in other hierarchies than the name=systemd:/ one. Takes a comma-separated list of controllers.]' \
238 '--private-network[Turn off networking in the container. This makes all network interfaces unavailable in the container, with the exception of the loopback device.]' \
239 '--read-only[Mount the root file system read only for the container.]' \
240 '--capability=[List one or more additional capabilities to grant the container.]:capabilities:_systemd-nspawn' \
241 "--link-journal=[Control whether the container's journal shall be made visible to the host system.]:options:(no, host, guest, auto)" \
242 '-j[Equivalent to --link-journal=guest.]'
246 '--create[Create, set ownership/permissions based on the config files.]' \
247 '--clean[Clean up all files and directories with an age parameter configured.]' \
248 '--remove[All files and directories marked with r, R in the configuration files are removed.]' \
249 '--prefix=[Only apply rules that apply to paths with the specified prefix.]' \
250 '--help[Prints a short help text and exits.]' \
253 systemd-tty-ask-password-agent)
255 {-h,--help}'[Prints a short help text and exits.]' \
256 '--version[Prints a short version string and exits.]' \
257 '--list[Lists all currently pending system password requests.]' \
258 '--query[Process all currently pending system password requests by querying the user on the calling TTY.]' \
259 '--watch[Continuously process password requests.]' \
260 '--wall[Forward password requests to wall(1).]' \
261 '--plymouth[Ask question with plymouth(8).]' \
262 '--console[Ask question on /dev/console.]'
270 _caps=( CAP_CHOWN CAP_DAC_OVERRIDE CAP_DAC_READ_SEARCH
271 CAP_FOWNER CAP_FSETID CAP_IPC_OWNER CAP_KILL CAP_LEASE CAP_LINUX_IMMUTABLE
272 CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW CAP_SETGID CAP_SETFCAP CAP_SETPCAP
273 CAP_SETUID CAP_SYS_ADMIN CAP_SYS_CHROOT CAP_SYS_NICE CAP_SYS_PTRACE CAP_SYS_TTY_CONFIG
274 CAP_SYS_RESOURCE CAP_SYS_BOOT )
275 _values -s , 'capabilities' "$_caps[@]"
278 _systemd_inhibit_command(){
279 if (( CURRENT == 1 )); then
283 local n=${words[(b:2:i)[^-]*]}
284 if (( n <= CURRENT )); then
287 'files:file:_files' \
288 'commands:command:_normal' && return 0
295 _systemd_analyze_command(){
296 local -a _systemd_analyze_cmds
297 _systemd_analyze_cmds=(
298 'time:Print the time taken to start'
299 'blame:prints a list of all running units, ordered by the time they took to initialize'
300 'plot:prints an SVG graphic detailing which system services have been started at what time'
301 'dot:Dump dependency graph for dot(1)'
304 if (( CURRENT == 1 )); then
305 _describe "options" _systemd_analyze_cmds
307 _message "no more options"
311 _hosts_or_user_at_host()
314 'users-hosts:: _user_at_host' \
319 local -a _output_opts
320 _output_opts=(short short-monotonic verbose export json json-pretty json-see cat)
321 _describe -t output 'output mode' _output_opts || compadd "$@"
325 (( $+functions[_systemctl_command] )) || _systemctl_command()
327 local -a _systemctl_cmds
329 "list-units:List units"
330 "start:Start (activate) one or more units"
331 "stop:Stop (deactivate) one or more units"
332 "reload:Reload one or more units"
333 "restart:Start or restart one or more units"
334 "condrestart:Restart one or more units if active"
335 "try-restart:Restart one or more units if active"
336 "reload-or-restart:Reload one or more units if possible, otherwise start or restart"
337 "force-reload:Reload one or more units if possible, otherwise restart if active"
338 "hibernate:Hibernate the system"
339 "hybrid-sleep:Hibernate and suspend the system"
340 "reload-or-try-restart:Reload one or more units if possible, otherwise restart if active"
341 "isolate:Start one unit and stop all others"
342 "kill:Send signal to processes of a unit"
343 "is-active:Check whether units are active"
344 "is-failed:Check whether units are failed"
345 "status:Show runtime status of one or more units"
346 "show:Show properties of one or more units/jobs or the manager"
347 "reset-failed:Reset failed state for all, one, or more units"
348 "load:Load one or more units"
349 "list-unit-files:List installed unit files"
350 "enable:Enable one or more unit files"
351 "disable:Disable one or more unit files"
352 "reenable:Reenable one or more unit files"
353 "preset:Enable/disable one or more unit files based on preset configuration"
354 "help:Show documentation for specified units"
355 "list-dependencies:Show unit dependency tree"
356 "mask:Mask one or more units"
357 "unmask:Unmask one or more units"
358 "link:Link one or more units files into the search path"
359 "is-enabled:Check whether unit files are enabled"
360 "list-jobs:List jobs"
361 "cancel:Cancel all, one, or more jobs"
362 "dump:Dump server status"
363 "snapshot:Create a snapshot"
364 "delete:Remove one or more snapshots"
365 "show-environment:Dump environment"
366 "set-environment:Set one or more environment variables"
367 "unset-environment:Unset one or more environment variables"
368 "daemon-reload:Reload systemd manager configuration"
369 "daemon-reexec:Reexecute systemd manager"
370 "default:Enter system default mode"
371 "rescue:Enter system rescue mode"
372 "emergency:Enter system emergency mode"
373 "halt:Shut down and halt the system"
374 "suspend:Suspend the system"
375 "poweroff:Shut down and power-off the system"
376 "reboot:Shut down and reboot the system"
377 "kexec:Shut down and reboot the system with kexec"
378 "exit:Ask for user instance termination"
381 if (( CURRENT == 1 )); then
382 _describe -t commands 'systemctl command' _systemctl_cmds || compadd "$@"
384 local curcontext="$curcontext"
386 cmd="${${_systemctl_cmds[(r)$words[1]:*]%%:*}}"
387 # Deal with any aliases
389 condrestart) cmd="try-restart";;
390 force-reload) cmd="reload-or-try-restart";;
394 curcontext="${curcontext%:*:*}:systemctl-${cmd}:"
397 zstyle -s ":completion:${curcontext}:" cache-policy update_policy
398 if [[ -z "$update_policy" ]]; then
399 zstyle ":completion:${curcontext}:" cache-policy _systemctl_caching_policy
402 _call_function ret _systemctl_$cmd || _message 'no more arguments'
404 _message "unknown systemctl command: $words[1]"
413 _modes=("--user" "--system")
414 systemctl ${words:*_modes} --full --no-legend --no-pager "$@"
418 # Fills the unit list
419 _systemctl_all_units()
421 if ( [[ ${+_sys_all_units} -eq 0 ]] || _cache_invalid SYS_ALL_UNITS ) &&
422 ! _retrieve_cache SYS_ALL_UNITS;
424 _sys_all_units=( $(__systemctl list-units --all | { while read a b; do echo " $a"; done; }) )
425 _store_cache SYS_ALL_UNITS _sys_all_units
429 # Fills the unit list including all file units
430 _systemctl_really_all_units()
432 local -a all_unit_files;
433 local -a really_all_units;
434 if ( [[ ${+_sys_really_all_units} -eq 0 ]] || _cache_invalid SYS_REALLY_ALL_UNITS ) &&
435 ! _retrieve_cache SYS_REALLY_ALL_UNITS;
437 all_unit_files=( $(__systemctl list-unit-files | { while read a b; do echo " $a"; done; }) )
439 really_all_units=($_sys_all_units $all_unit_files)
440 _sys_really_all_units=(${(u)really_all_units})
441 _store_cache SYS_REALLY_ALL_UNITS _sys_really_all_units
445 _filter_units_by_property() {
446 local property=$1 value=$2 ; shift ; shift
447 local -a units ; units=($*)
449 for ((i=1; $i <= ${#units[*]}; i++)); do
450 # FIXME: "Failed to issue method call: Unknown unit" errors are ignored for
451 # now (related to DBUS_ERROR_UNKNOWN_OBJECT). in the future, we need to
452 # revert to calling 'systemctl show' once for all units, which is way
455 prop=${(f)"$(_call_program units "$service show --no-pager --property="$property" ${unit} 2>/dev/null")"}
456 if [[ "${prop}" = "$property=$value" ]]; then
462 _systemctl_active_units() {_sys_active_units=( $(__systemctl list-units | { while read a b; do echo " $a"; done; }) )}
463 _systemctl_inactive_units(){_sys_inactive_units=($(__systemctl list-units --all | { while read a b c d; do [[ $c == "inactive" || $c == "failed" ]] && echo " $a"; done; }) )}
464 _systemctl_failed_units() {_sys_failed_units=( $(__systemctl list-units --failed | { while read a b; do echo " $a"; done; }) )}
465 _systemctl_enabled_units() {_sys_enabled_units=( $(__systemctl list-unit-files | { while read a b; do [[ $b == "enabled" ]] && echo " $a"; done; }) )}
466 _systemctl_disabled_units(){_sys_disabled_units=($(__systemctl list-unit-files | { while read a b; do [[ $b == "disabled" ]] && echo " $a"; done; }) )}
467 _systemctl_masked_units() {_sys_masked_units=( $(__systemctl list-unit-files | { while read a b; do [[ $b == "masked" ]] && echo " $a"; done; }) )}
469 # Completion functions for ALL_UNITS
470 for fun in is-active is-failed is-enabled status show mask preset help list-dependencies ; do
471 (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
473 _systemctl_really_all_units
474 compadd "$@" -a - _sys_really_all_units
478 # Completion functions for ENABLED_UNITS
479 for fun in disable reenable ; do
480 (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
482 _systemctl_enabled_units
483 _systemctl_disabled_units
484 compadd "$@" -a - _sys_enabled_units _sys_disabled_units
488 # Completion functions for DISABLED_UNITS
489 (( $+functions[_systemctl_enable] )) || _systemctl_enable()
491 _systemctl_disabled_units
492 compadd "$@" -a - _sys_disabled_units
495 # Completion functions for FAILED_UNITS
496 (( $+functions[_systemctl_reset-failed] )) || _systemctl_reset-failed()
498 _systemctl_failed_units
499 compadd "$@" -a - _sys_failed_units || _message "no failed unit found"
502 # Completion functions for STARTABLE_UNITS
503 (( $+functions[_systemctl_start] )) || _systemctl_start()
505 _systemctl_inactive_units
506 compadd "$@" -a - _sys_inactive_units
509 # Completion functions for STOPPABLE_UNITS
510 for fun in stop kill try-restart condrestart ; do
511 (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
513 _systemctl_active_units
514 compadd "$@" - $( _filter_units_by_property CanStop yes \
515 ${_sys_active_units[*]} )
519 # Completion functions for ISOLATABLE_UNITS
520 (( $+functions[_systemctl_isolate] )) || _systemctl_isolate()
523 compadd "$@" - $( _filter_units_by_property AllowIsolate yes \
524 ${_sys_all_units[*]} )
527 # Completion functions for RELOADABLE_UNITS
528 for fun in reload reload-or-try-restart force-reload ; do
529 (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
531 _systemctl_active_units
532 compadd "$@" - $( _filter_units_by_property CanReload yes \
533 ${_sys_active_units[*]} )
537 # Completion functions for RESTARTABLE_UNITS
538 for fun in restart reload-or-restart ; do
539 (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
542 compadd "$@" - $( _filter_units_by_property CanStart yes \
543 ${_sys_all_units[*]} | while read line; do \
544 [[ "$line" =~ \.device$ ]] || echo " $line"; \
549 # Completion functions for MASKED_UNITS
550 (( $+functions[_systemctl_unmask] )) || _systemctl_unmask()
552 _systemctl_masked_units
553 compadd "$@" -a - _sys_masked_units || _message "no masked unit found"
556 # Completion functions for JOBS
557 (( $+functions[_systemctl_cancel] )) || _systemctl_cancel()
559 compadd "$@" - $(__systemctl list-jobs \
560 | cut -d' ' -f1 2>/dev/null ) || _message "no job found"
563 # Completion functions for SNAPSHOTS
564 (( $+functions[_systemctl_delete] )) || _systemctl_delete()
566 compadd "$@" - $(__systemctl list-units --type snapshot --all \
567 | cut -d' ' -f1 2>/dev/null ) || _message "no snapshot found"
570 # Completion functions for ENVS
571 for fun in set-environment unset-environment ; do
572 (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
574 local fun=$0 ; fun=${fun##_systemctl_}
576 if [[ "${fun}" = "set-environment" ]]; then
580 compadd "$@" ${suf} - $(systemctl show-environment \
581 | while read line; do echo " ${line%%\=}";done )
585 (( $+functions[_systemctl_link] )) || _systemctl_link() { _files }
587 # no systemctl completion for:
588 # [STANDALONE]='daemon-reexec daemon-reload default dump
589 # emergency exit halt kexec list-jobs list-units
590 # list-unit-files poweroff reboot rescue show-environment'
591 # [NAME]='snapshot load'
593 _systemctl_caching_policy()
598 # rebuild if cache is more than a day old
599 oldcache=( "$1"(mh+1) )
600 (( $#oldcache )) && return 0
602 _sysunits=($(__systemctl --all | cut -d' ' -f1))
604 if (( $#_sysunits )); then
605 for unit in $_sysunits; do
606 [[ "$unit" -nt "$1" ]] && return 0
614 local -a journal_fields
615 journal_fields=(MESSAGE{,_ID} PRIORITY CODE_{FILE,LINE,FUNC}
616 ERRNO SYSLOG_{FACILITY,IDENTIFIER,PID}
617 _{P,U,G}ID _COMM _EXE _CMDLINE
618 _AUDIT_{SESSION,LOGINUID}
619 _SYSTEMD_{CGROUP,SESSION,UNIT,OWNER_UID}
621 _SELINUX_CONTEXT _SOURCE_REALTIME_TIMESTAMP
622 _{BOOT,MACHINE}_ID _HOSTNAME _TRANSPORT
623 _KERNEL_{DEVICE,SUBSYSTEM}
624 _UDEV_{SYSNAME,DEVNODE,DEVLINK}
625 __CURSOR __{REALTIME,MONOTONIC}_TIMESTAMP)
626 _describe 'possible fields' journal_fields
630 local -a _commands _files
631 _commands=( ${(f)"$(_call_program commands "$service" -F _EXE 2>/dev/null)"} )
633 'files:/dev files:_files -W /dev -P /dev/' \
634 "commands:commands:($_commands[@])" \
635 'fields:fields:_list_fields'
640 cmd=("journalctl" "-F ${@[-1]}" "2>/dev/null" )
641 _fields=( ${(f)"$(_call_program fields $cmd[@])"} )
643 _describe 'possible values' _fields
647 _loginctl_all_sessions(){_sys_all_sessions=($(loginctl list-sessions | { while read a b; do echo " $a"; done; }) )}
648 _loginctl_all_users() {_sys_all_users=( $(loginctl list-users | { while read a b; do echo " $a"; done; }) )}
649 _loginctl_all_seats() {_sys_all_seats=( $(loginctl list-seats | { while read a b; do echo " $a"; done; }) )}
651 # Completion functions for SESSIONS
652 for fun in session-status show-session activate lock-session unlock-session terminate-session kill-session ; do
653 (( $+functions[_loginctl_$fun] )) || _loginctl_$fun()
655 _loginctl_all_sessions
656 compadd "$@" -a - _sys_all_sessions
660 # Completion functions for USERS
661 for fun in user-status show-user enable-linger disable-linger terminate-user kill-user ; do
662 (( $+functions[_loginctl_$fun] )) || _loginctl_$fun()
665 compadd "$@" -a - _sys_all_users
669 # Completion functions for SEATS
670 (( $+functions[_loginctl_seats] )) || _loginctl_seats()
673 compadd "$@" -a - _sys_all_seats
675 for fun in seat-status show-seat terminate-seat ; do
676 (( $+functions[_loginctl_$fun] )) || _loginctl_$fun()
680 # Completion functions for ATTACH
681 (( $+functions[_loginctl_attach] )) || _loginctl_attach()
685 _arguments -w -C -S -s \
686 ':seat:_loginctl_seats' \
690 # no loginctl completion for:
691 # [STANDALONE]='list-sessions list-users list-seats flush-devices'
693 (( $+functions[_loginctl_command] )) || _loginctl_command()
695 local -a _loginctl_cmds
697 "list-sessions:List sessions"
698 "session-status:Show session status"
699 "show-session:Show properties of one or more sessions"
700 "activate:Activate a session"
701 "lock-session:Screen lock one or more sessions"
702 "unlock-session:Screen unlock one or more sessions"
703 "terminate-session:Terminate one or more sessions"
704 "kill-session:Send signal to processes of a session"
705 "list-users:List users"
706 "user-status:Show user status"
707 "show-user:Show properties of one or more users"
708 "enable-linger:Enable linger state of one or more users"
709 "disable-linger:Disable linger state of one or more users"
710 "terminate-user:Terminate all sessions of one or more users"
711 "kill-user:Send signal to processes of a user"
712 "list-seats:List seats"
713 "seat-status:Show seat status"
714 "show-seat:Show properties of one or more seats"
715 "attach:Attach one or more devices to a seat"
716 "flush-devices:Flush all device associations"
717 "terminate-seat:Terminate all sessions on one or more seats"
720 if (( CURRENT == 1 )); then
721 _describe -t commands 'loginctl command' _loginctl_cmds || compadd "$@"
723 local curcontext="$curcontext"
725 cmd="${${_loginctl_cmds[(r)$words[1]:*]%%:*}}"
728 curcontext="${curcontext%:*:*}:loginctl-${cmd}:"
730 _call_function ret _loginctl_$cmd || _message 'no more arguments'
732 _message "unknown loginctl command: $words[1]"
738 _hostnamectl_command() {
739 local -a _hostnamectl_cmds
741 "status:Show current hostname settings"
742 "set-hostname:Set system hostname"
743 "set-icon-name:Set icon name for host"
745 if (( CURRENT == 1 )); then
746 _describe -t commands 'hostnamectl commands' _hostnamectl_cmds || compadd "$@"
748 local curcontext="$curcontext"
749 cmd="${${_hostnamectl_cmds[(r)$words[1]:*]%%:*}}"
751 [[ $cmd == status ]] && msg="no options" || msg="options for $cmd"
754 _message "unknown hostnamectl command: $words[1]"
759 _localectl_set-locale() {
760 local -a _confs _locales
762 _locales=( ${(f)"$(_call_program locales "$service" list-locales)"} )
763 _confs=( ${${(f)"$(_call_program confs "locale 2>/dev/null")"}%\=*} )
764 if [[ -prefix 1 *\= ]]; then
765 local conf=${PREFIX%%\=*}
767 _wanted locales expl "locales configs" \
768 _combination localeconfs confs=$conf locales "$@" -
770 compadd -S '=' $_confs
774 _localectl_set-keymap() {
776 _keymaps=( ${(f)"$(_call_program locales "$service" list-keymaps)"} )
777 if (( CURRENT <= 3 )); then
778 _describe keymaps _keymaps
780 _message "no more options"
784 _localectl_set-x11-keymap() {
785 if (( $+commands[pkg-config] )); then
786 local -a _file _layout _model _variant _options
788 _xorg_lst=${"$($commands[pkg-config] xkeyboard-config --variable=xkb_base)"}
789 _file=( ${(ps:\n\!:)"$(<$_xorg_lst/rules/xorg.lst)"} )
790 _layout=( ${${${(M)${(f)_file[1]}:# *}# }%% *} )
791 _model=( ${${${(M)${(f)_file[2]}:# *}# }%% *} )
792 _variant=( ${${${(M)${(f)_file[3]}:# *}# }%% *} )
793 _options=( ${${${(M)${(f)_file[4]}:# *}# }%% *} )
794 #_layout=( ${(f)"$( echo $_file[1] | awk '/^ / {print $1}' )"} )
795 #_model=( ${(f)"$(echo $_file[2] | awk '/^ / {print $1}')"} )
796 #_variant=( ${(f)"$(echo $_file[3] | awk '/^ / {print $1}')"} )
797 #_options=( ${(f)"$(echo ${_file[4]//:/\\:} | awk '/^ / {print $1}')"} )
800 2) _describe layouts _layout ;;
801 3) _describe models _model;;
802 4) _describe variants _variant;;
803 5) _describe options _options;;
804 *) _message "no more options"
810 _localectl_command() {
811 local -a _localectl_cmds
813 'status:Show current locale settings'
814 'set-locale:Set system locale'
815 'list-locales:Show known locales'
816 'set-keymap:Set virtual console keyboard mapping'
817 'list-keymaps:Show known virtual console keyboard mappings'
818 'set-x11-keymap:Set X11 keyboard mapping'
820 if (( CURRENT == 1 )); then
821 _describe -t commands 'localectl command' _localectl_cmds
823 local curcontext="$curcontext"
824 cmd="${${_localectl_cmds[(r)$words[1]:*]%%:*}}"
825 if (( $+functions[_localectl_$cmd] )); then
828 _message "no more options"
833 _timedatectl_set-timezone(){
835 _timezones=( ${(f)"$(_call_program timezones "${service}" list-timezones)"} )
836 compadd "$_timezones[@]"
839 _timedatectl_set-time(){
840 _message "YYYY-MM-DD HH:MM:SS"
843 _timedatectl_set-local-rtc(){
846 '0:Maintain RTC in universal time'
847 '1:Maintain RTC in local time'
849 _describe options _options
852 _timedatectl_set-ntp(){
855 '0:Disable NTP based network time configuration'
856 '1:Enable NTP based network time configuration'
858 _describe options _options
861 _timedatectl_command(){
862 local -a _timedatectl_cmds
864 'status:Show current time settings'
865 'set-time:Set system time'
866 'set-timezone:Set system timezone'
867 'list-timezones:Show known timezones'
868 'set-local-rtc:Control whether RTC is in local time'
869 'set-ntp:Control whether NTP is enabled'
871 if (( CURRENT == 1 )); then
872 _describe -t commands 'timedatectl command' _timedatectl_cmds
874 local curcontext="$curcontext"
875 cmd="${${_timedatectl_cmds[(r)$words[1]:*]%%:*}}"
877 if (( $+functions[_timedatectl_$cmd] )); then
880 _message "no more options"
883 _message "unknown timedatectl command: $words[1]"
887 _systemd-coredumpctl_command(){
888 local -a _systemd_coredumpctl_cmds
889 _systemd_coredumpctl_cmds=(
890 'list:List available coredumps'
891 'dump:Print coredump to std'
893 if (( CURRENT == 1 )); then
894 _describe -t commands 'systemd-coredumpctl command' _systemd_coredumpctl_cmds
896 local curcontext="$curcontext"
898 cmd="${${_systemd_coredumpctl_cmds[(r)$words[1]:*]%%:*}}"
900 dumps=( "${(f)$(_call_program dumps "systemd-coredumpctl list 2>/dev/null")}" )
901 if [[ -n "$dumps" ]]; then
902 compadd "${dumps[@]}"
904 _message "no coredumps"
907 _message "no more options"
916 '--query=[Query the database for specified type of device data. It needs the --path or --name to identify the specified device.]:type:(name symlink path property all)' \
917 '--path=[The devpath of the device to query.]:sys files:_files -P /sys/ -W /sys' \
918 '--name=[The name of the device node or a symlink to query]:device files:_files -P /dev/ -W /dev' \
919 '--root[Print absolute paths in name or symlink query.]' \
920 '--attribute-walk[Print all sysfs properties of the specified device that can be used in udev rules to match the specified device]' \
921 '--export[Print output as key/value pairs.]' \
922 '--export-prefix=[Add a prefix to the key name of exported values.]:prefix' \
923 '--device-id-of-file=[Print major/minor numbers of the underlying device, where the file lives on.]:files:_udevadm_mounts' \
924 '--export-db[Export the content of the udev database.]' \
925 '--cleanup-db[Cleanup the udev database.]'
930 '--verbose[Print the list of devices which will be triggered.]' \
931 '--dry-run[Do not actually trigger the event.]' \
932 '--type=[Trigger a specific type of devices.]:types:(devices subsystems failed)' \
933 '--action=[Type of event to be triggered.]:actions:(add change remove)' \
934 '--subsystem-match=[Trigger events for devices which belong to a matching subsystem.]' \
935 '--subsystem-nomatch=[Do not trigger events for devices which belong to a matching subsystem.]' \
936 '--attr-match=attribute=[Trigger events for devices with a matching sysfs attribute.]' \
937 '--attr-nomatch=attribute=[Do not trigger events for devices with a matching sysfs attribute.]' \
938 '--property-match=[Trigger events for devices with a matching property value.]' \
939 '--tag-match=property[Trigger events for devices with a matching tag.]' \
940 '--sysname-match=[Trigger events for devices with a matching sys device name.]' \
941 '--parent-match=[Trigger events for all children of a given device.]'
946 '--timeout=[Maximum number of seconds to wait for the event queue to become empty.]' \
947 '--seq-start=[Wait only for events after the given sequence number.]' \
948 '--seq-end=[Wait only for events before the given sequence number.]' \
949 '--exit-if-exists=[Stop waiting if file exists.]:files:_files' \
950 '--quiet[Do not print any output, like the remaining queue entries when reaching the timeout.]' \
951 '--help[Print help text.]'
956 '--exit[Signal and wait for systemd-udevd to exit.]' \
957 '--log-priority=[Set the internal log level of systemd-udevd.]:priorities:(err info debug)' \
958 '--stop-exec-queue[Signal systemd-udevd to stop executing new events. Incoming events will be queued.]' \
959 '--start-exec-queue[Signal systemd-udevd to enable the execution of events.]' \
960 '--reload[Signal systemd-udevd to reload the rules files and other databases like the kernel module index.]' \
961 '--property=[Set a global property for all events.]' \
962 '--children-max=[Set the maximum number of events.]' \
963 '--timeout=[The maximum number of seconds to wait for a reply from systemd-udevd.]' \
964 '--help[Print help text.]'
969 '--kernel[Print the kernel uevents.]' \
970 '--udev[Print the udev event after the rule processing.]' \
971 '--property[Also print the properties of the event.]' \
972 '--subsystem-match=[Filter events by subsystem[/devtype].]' \
973 '--tag-match=[Filter events by property.]' \
974 '--help[Print help text.]'
979 '--action=[The action string.]:actions:(add change remove)' \
980 '--subsystem=[The subsystem string.]' \
981 '--help[Print help text.]' \
982 '*::devpath:_files -P /sys/ -W /sys'
985 _udevadm_test-builtin(){
986 if (( CURRENT == 2 )); then
988 '--help[Print help text]' \
989 '*::builtins:(blkid btrfs hwdb input_id kmod path_id usb_id uaccess)'
990 elif (( CURRENT == 3 )); then
992 '--help[Print help text]' \
993 '*::syspath:_files -P /sys -W /sys'
996 '--help[Print help text]'
1001 local dev_tmp dpath_tmp mp_tmp mline
1003 tmp=( "${(@f)$(< /etc/mtab)}" )
1004 dev_tmp=( "${(@)${(@)tmp%% *}:#none}" )
1005 mp_tmp=( "${(@)${(@)tmp#* }%% *}" )
1008 mp_tmp=("${(@q)mp_tmp//(#m)\\[0-7](#c3)/${(#)$(( 8#${MATCH[2,-1]} ))}}")
1009 dpath_tmp=( "${(@Mq)dev_tmp:#/*}" )
1010 dev_tmp=( "${(@q)dev_tmp:#/*}" )
1013 'device-paths: device path:compadd -a dpath_tmp' \
1014 'directories:mount point:compadd -a mp_tmp'
1019 local -a _udevadm_cmds
1021 'info:query sysfs or the udev database'
1022 'trigger:request events from the kernel'
1023 'settle:wait for the event queue to finish'
1024 'control:control the udev daemon'
1025 'monitor:listen to kernel and udev events'
1026 'test:test an event run'
1027 'test-builtin:test a built-in command'
1030 if ((CURRENT == 1)); then
1031 _describe -t commands 'udevadm commands' _udevadm_cmds
1033 local curcontext="$curcontext"
1034 cmd="${${_udevadm_cmds[(r)$words[1]:*]%%:*}}"
1036 if (( $+functions[_udevadm_$cmd] )); then
1039 _message "no options for $cmd"
1042 _message "no more options"
1049 #vim: set ft=zsh sw=4 ts=4 et