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 '--failed[Show only failed units]' \
16 "--full[Don't ellipsize unit names on output]" \
17 '--fail[When queueing a new job, fail if conflicting jobs are pending]' \
18 '--ignore-dependencies[When queueing a new job, ignore all its dependencies]' \
19 '--kill-who=[Who to send signal to]:killwho:(main control all)' \
20 {-s,--signal=}'[Which signal to send]:signal:_signals' \
21 {-H,--host=}'[Show information for remote host]:userathost:_hosts_or_user_at_host' \
22 {-P,--privileged}'[Acquire privileges before execution]' \
23 {-q,--quiet}'[Suppress output]' \
24 '--no-block[Do not wait until operation finished]' \
25 "--no-wall[Don't send wall message before halt/power-off/reboot]" \
26 "--no-reload[When enabling/disabling unit files, don't reload daemon configuration]" \
27 '--no-legend[Do not print a legend, i.e. the column headers and the footer with hints]' \
28 '--no-pager[Do not pipe output into a pager]' \
29 '--no-ask-password[Do not ask for system passwords]' \
30 '--system[Connect to system manager]' \
31 '--user[Connect to user service manager]' \
32 '--global[Enable/disable unit files globally]' \
33 {-f,--force}'[When enabling unit files, override existing symlinks. When shutting down, execute action immediately]' \
34 '--root=[Enable unit files in the specified root directory]:directory:_directories' \
35 '--runtime[Enable unit files only temporarily until next reboot]' \
36 {-n,--lines=}'[Journal entries to show]:number of entries' \
37 {-o,--output=}'[Change journal output mode]:modes:_outputmodes' \
38 '*::systemctl command:_systemctl_command'
42 {-h,--help}'[Show help]' \
43 '--version[Show package version]' \
44 \*{-p,--property=}'[Show only properties by this name]:unit property' \
45 {-a,--all}'[Show all properties, including empty ones]' \
46 '--kill-who=[Who to send signal to]:killwho:(main control all)' \
47 {-s,--signal=}'[Which signal to send]:signal:_signals' \
48 '--no-ask-password[Do not ask for system passwords]' \
49 {-H,--host=}'[Show information for remote host]:userathost:_hosts_or_user_at_host' \
50 {-P,--privileged}'[Acquire privileges before execution]' \
51 '--no-pager[Do not pipe output into a pager]' \
52 '*::loginctl command:_loginctl_command'
57 {-h,--help}'[Show this help]' \
58 '--version[Show package version]' \
59 '--transient[Only set transient hostname]' \
60 '--static[Only set static hostname]' \
61 '--pretty[Only set pretty hostname]' \
62 '--no-ask-password[Do not prompt for password]' \
63 {-H,--host=}'[Operate on remote host]:userathost:_hosts_or_user_at_host' \
64 '*::hostnamectl commands:_hostnamectl_command'
68 '--since=[Start showing entries newer or of the specified date]:YYYY-MM-DD HH\:MM\:SS' \
69 '--until=[Stop showing entries older or of the specified date]:YYYY-MM-DD HH\:MM\:SS' \
70 {-c,--cursor=}'[Start showing entries from specified cursor]:cursors:_journal_fields __CURSORS' \
71 {-b,--this-boot}'[Show data only from current boot]' \
72 {-u,--unit=}'[Show data only from the specified unit]:units:_journal_fields _SYSTEMD_UNIT' \
73 '--user-unit[Show data only from the specified user session unit]:units:_journal_fields _SYSTEMD_USER_UNIT' \
74 {-p,--priority=}'[Show only messages within the specified priority range]:priority:_journal_fields PRIORITY' \
75 {-f,--follow}'[Follow journal]' \
76 {-n,--lines=}'[Number of journal entries to show]:integer' \
77 '--no-tail[Show all lines, even in follow mode]' \
78 {-o,--output=}'[Change journal output mode]:output modes:_outputmodes' \
79 '--full[Show long fields in full]' \
80 {-a,--all}'[Show all fields, including long and unprintable]' \
81 {-q,--quiet}"[Don't show privilege warning]" \
82 '--no-pager[Do not pipe output into a pager]' \
83 {-m,--merge}'[Show entries from all available journals]' \
84 {-D,--directory=}'[Show journal files from directory]:directories:_directories' \
85 '--interval=[Time interval for changing the FSS sealing key]:time interval' \
86 '--verify-key=[Specify FSS verification key]:FSS key' \
87 {-h,--help}'[Show this help]' \
88 '--version[Show package version]' \
89 '--new-id128[Generate a new 128 Bit ID]' \
90 '--header[Show journal header information]' \
91 '--disk-usage[Show total disk usage]' \
92 {-F,--field=}'[List all values a certain field takes]:Fields:_list_fields' \
93 '--setup-keys[Generate new FSS key pair]' \
94 '--verify[Verify journal file consistency]' \
95 '--list-catalog[List messages in catalog]' \
96 '--update-catalog[Update binary catalog database]' \
100 {-h,--help}'[Show this help]' \
101 '--version[Show package version]' \
102 "--no-convert[Don't convert keyboard mappings]" \
103 '--no-pager[Do not pipe output into a pager]' \
104 '--no-ask-password[Do not prompt for password]' \
105 {-H,--host=}'[Operate on remote host]:userathost:_hosts_or_user_at_host' \
106 '*::localectl commands:_localectl_command'
110 {-o,--output=}'[Write output to FILE]:output file:_files' \
111 '--no-pager[Do not pipe output into a pager]' \
112 {-h,--help}'[Show this help]' \
113 '--version[Show package version]' \
114 '*::systemd-coredumpctl commands:_systemd-coredumpctl_command'
119 {-h,--help}'[Show this help]' \
120 '--version[Show package version]' \
121 '--adjust-system-clock[Adjust system clock when changing local RTC mode]' \
122 '--no-pager[Do not pipe output into a pager]' \
123 '--no-ask-password[Do not prompt for password]' \
124 {-H,--host=}'[Operate on remote host]:userathost:_hosts_or_user_at_host' \
125 '*::timedatectl commands:_timedatectl_command'
129 '--debug[Print debug messages to stderr]' \
130 '--version[Print version number]' \
131 '--help[Print help text]' \
132 '*::udevadm commands:_udevadm_command'
136 {-h,--help}'[Show help text.]' \
137 '--user[Shows performance data of user sessions instead of the system manager.]' \
138 '--order[When generating graph for dot, show only order]' \
139 '--require[When generating graph for dot, show only requirement]' \
140 '*::systemd-analyze commands:_systemd_analyze_command'
142 systemd-ask-password)
144 {-h,--help}'[Show this help]' \
145 '--icon=[Icon name]' \
146 '--timeout=[Timeout in sec]' \
147 '--no-tty[Ask question via agent even on TTY]' \
148 '--accept-cached[Accept cached passwords]' \
149 '--multiple[List multiple passwords if available]'
153 {-h,--help}'[Show this help]' \
154 '--version[Show package version.]' \
155 {-t,--identifier=}'[Set syslog identifier.]' \
156 {-p,--priority=}'[Set priority value.]:value:({0..7})' \
157 '--level-prefix=[Control whether level prefix shall be parsed.]:boolean:(1 0)' \
162 {-h,--help}'[Show this help]' \
163 '--version[Show package version]' \
164 '--no-pager[Do not pipe output into a pager]' \
165 {-a,--all}'[Show all groups, including empty]' \
166 '-k[Include kernel threads in output]' \
167 ':cgroups:(cpuset cpu cpuacct memory devices freezer net_cls blkio)'
171 {-h,--help}'[Show this help]' \
172 '--version[Print version and exit]' \
173 '(-c -m -i -t)-p[Order by path]' \
174 '(-c -p -m -i)-t[Order by number of tasks]' \
175 '(-m -p -i -t)-c[Order by CPU load]' \
176 '(-c -p -i -t)-m[Order by memory load]' \
177 '(-c -m -p -t)-i[Order by IO load]' \
178 {-d,--delay=}'[Specify delay]' \
179 {-n,--iterations=}'[Run for N iterations before exiting]' \
180 {-b,--batch}'[Run in batch mode, accepting no input]' \
181 '--depth=[Maximum traversal depth]'
185 {-h,--help}'[Show this help]' \
186 '--version[Show package version]' \
187 '--no-pager[Do not pipe output into a pager]' \
188 '--diff=[Show a diff when overridden files differ]:boolean:(1 0)' \
189 {-t,--type=}'[Only display a selected set of override types]:types:(masked equivalent redirected overridden unchanged)' \
190 ':SUFFIX:(tmpfiles.d sysctl.d systemd/system)'
194 {-h,--help}'[Show this help]' \
195 '--version[Show package version]' \
196 {-c,--container}'[Only detect whether we are run in a container]' \
197 {-v,--vm}'[Only detect whether we are run in a VM]' \
198 {-q,--quiet}"[Don't output anything, just set return value]"
202 {-h,--help}'[Show this help]' \
203 '--version[Show package version]' \
204 '--what=[Operations to inhibit]:options:(shutdown sleep idle handle-power-key handle-suspend-key handle-hibernate-key handle-lid-switch)' \
205 '--who=[A descriptive string who is inhibiting]' \
206 '--why=[A descriptive string why is being inhibited]' \
207 '--mode=[One of block or delay]' \
208 '--list[List active inhibitors]' \
209 '*:commands:_systemd_inhibit_command'
211 systemd-machine-id-setup)
213 {-h,--help}'[Show this help]' \
214 '--version[Show package version]'
218 {-h,--help}'[Show this help]' \
219 '--version[Show package version]' \
220 '--ready[Inform the init system about service start-up completion.]' \
221 '--pid=[Inform the init system about the main PID of the daemon]' \
222 '--status=[Send a free-form status string for the daemon to the init systemd]' \
223 '--booted[Returns 0 if the system was booted up with systemd]' \
224 '--readahead=[Controls disk read-ahead operations]:arguments:(cancel done noreply)'
228 {-h,--help}'[Show this help]' \
229 {--directory=,-D}'[Directory to use as file system root for the namespace container. If omitted the current directory will be used.]:directories:_directories' \
230 {--boot,-b}'[Automatically search for an init binary and invoke it instead of a shell or a user supplied program.]' \
231 {--user=,-u}'[Run the command under specified user, create home directory and cd into it.]' \
232 '--uuid=[Set the specified uuid for the container.]' \
233 {--controllers=,-C}'[Makes the container appear in other hierarchies than the name=systemd:/ one. Takes a comma-separated list of controllers.]' \
234 '--private-network[Turn off networking in the container. This makes all network interfaces unavailable in the container, with the exception of the loopback device.]' \
235 '--read-only[Mount the root file system read only for the container.]' \
236 '--capability=[List one or more additional capabilities to grant the container.]:capabilities:_systemd-nspawn' \
237 "--link-journal=[Control whether the container's journal shall be made visible to the host system.]:options:(no, host, guest, auto)" \
238 '-j[Equivalent to --link-journal=guest.]'
242 '--create[Create, set ownership/permissions based on the config files.]' \
243 '--clean[Clean up all files and directories with an age parameter configured.]' \
244 '--remove[All files and directories marked with r, R in the configuration files are removed.]' \
245 '--prefix=[Only apply rules that apply to paths with the specified prefix.]' \
246 '--help[Prints a short help text and exits.]' \
249 systemd-tty-ask-password-agent)
251 {-h,--help}'[Prints a short help text and exits.]' \
252 '--version[Prints a short version string and exits.]' \
253 '--list[Lists all currently pending system password requests.]' \
254 '--query[Process all currently pending system password requests by querying the user on the calling TTY.]' \
255 '--watch[Continuously process password requests.]' \
256 '--wall[Forward password requests to wall(1).]' \
257 '--plymouth[Ask question with plymouth(8).]' \
258 '--console[Ask question on /dev/console.]'
266 _caps=( CAP_CHOWN CAP_DAC_OVERRIDE CAP_DAC_READ_SEARCH
267 CAP_FOWNER CAP_FSETID CAP_IPC_OWNER CAP_KILL CAP_LEASE CAP_LINUX_IMMUTABLE
268 CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW CAP_SETGID CAP_SETFCAP CAP_SETPCAP
269 CAP_SETUID CAP_SYS_ADMIN CAP_SYS_CHROOT CAP_SYS_NICE CAP_SYS_PTRACE CAP_SYS_TTY_CONFIG
270 CAP_SYS_RESOURCE CAP_SYS_BOOT )
271 _values -s , 'capabilities' "$_caps[@]"
274 _systemd_inhibit_command(){
275 if (( CURRENT == 1 )); then
279 local n=${words[(b:2:i)[^-]*]}
280 if (( n <= CURRENT )); then
283 'files:file:_files' \
284 'commands:command:_normal' && return 0
291 _systemd_analyze_command(){
292 local -a _systemd_analyze_cmds
293 _systemd_analyze_cmds=(
294 'time:Print the time taken to start'
295 'blame:prints a list of all running units, ordered by the time they took to initialize'
296 'plot:prints an SVG graphic detailing which system services have been started at what time'
297 'dot:Dump dependency graph for dot(1)'
300 if (( CURRENT == 1 )); then
301 _describe "options" _systemd_analyze_cmds
303 _message "no more options"
307 _hosts_or_user_at_host()
310 'users-hosts:: _user_at_host' \
315 local -a _output_opts
316 _output_opts=(short short-monotonic verbose export json json-pretty json-see cat)
317 _describe -t output 'output mode' _output_opts || compadd "$@"
321 (( $+functions[_systemctl_command] )) || _systemctl_command()
323 local -a _systemctl_cmds
325 "list-units:List units"
326 "start:Start (activate) one or more units"
327 "stop:Stop (deactivate) one or more units"
328 "reload:Reload one or more units"
329 "restart:Start or restart one or more units"
330 "condrestart:Restart one or more units if active"
331 "try-restart:Restart one or more units if active"
332 "reload-or-restart:Reload one or more units if possible, otherwise start or restart"
333 "force-reload:Reload one or more units if possible, otherwise restart if active"
334 "hibernate:Hibernate the system"
335 "hybrid-sleep:Hibernate and suspend the system"
336 "reload-or-try-restart:Reload one or more units if possible, otherwise restart if active"
337 "isolate:Start one unit and stop all others"
338 "kill:Send signal to processes of a unit"
339 "is-active:Check whether units are active"
340 "is-failed:Check whether units are failed"
341 "status:Show runtime status of one or more units"
342 "show:Show properties of one or more units/jobs or the manager"
343 "reset-failed:Reset failed state for all, one, or more units"
344 "load:Load one or more units"
345 "list-unit-files:List installed unit files"
346 "enable:Enable one or more unit files"
347 "disable:Disable one or more unit files"
348 "reenable:Reenable one or more unit files"
349 "preset:Enable/disable one or more unit files based on preset configuration"
350 "mask:Mask one or more units"
351 "unmask:Unmask one or more units"
352 "link:Link one or more units files into the search path"
353 "is-enabled:Check whether unit files are enabled"
354 "list-jobs:List jobs"
355 "cancel:Cancel all, one, or more jobs"
356 "dump:Dump server status"
357 "snapshot:Create a snapshot"
358 "delete:Remove one or more snapshots"
359 "show-environment:Dump environment"
360 "set-environment:Set one or more environment variables"
361 "unset-environment:Unset one or more environment variables"
362 "daemon-reload:Reload systemd manager configuration"
363 "daemon-reexec:Reexecute systemd manager"
364 "default:Enter system default mode"
365 "rescue:Enter system rescue mode"
366 "emergency:Enter system emergency mode"
367 "halt:Shut down and halt the system"
368 "suspend:Suspend the system"
369 "poweroff:Shut down and power-off the system"
370 "reboot:Shut down and reboot the system"
371 "kexec:Shut down and reboot the system with kexec"
372 "exit:Ask for user instance termination"
375 if (( CURRENT == 1 )); then
376 _describe -t commands 'systemctl command' _systemctl_cmds || compadd "$@"
378 local curcontext="$curcontext"
380 cmd="${${_systemctl_cmds[(r)$words[1]:*]%%:*}}"
381 # Deal with any aliases
383 condrestart) cmd="try-restart";;
384 force-reload) cmd="reload-or-try-restart";;
388 curcontext="${curcontext%:*:*}:systemctl-${cmd}:"
391 zstyle -s ":completion:${curcontext}:" cache-policy update_policy
392 if [[ -z "$update_policy" ]]; then
393 zstyle ":completion:${curcontext}:" cache-policy _systemctl_caching_policy
396 _call_function ret _systemctl_$cmd || _message 'no more arguments'
398 _message "unknown systemctl command: $words[1]"
406 systemctl --full --no-legend --no-pager "$@"
410 # Fills the unit list
411 _systemctl_all_units()
413 if ( [[ ${+_sys_all_units} -eq 0 ]] || _cache_invalid SYS_ALL_UNITS ) &&
414 ! _retrieve_cache SYS_ALL_UNITS;
416 _sys_all_units=( $(__systemctl list-units --all | { while read a b; do echo "$a"; done; }) )
417 _store_cache SYS_ALL_UNITS _sys_all_units
421 # Fills the unit list including all file units
422 _systemctl_really_all_units()
424 local -a all_unit_files;
425 local -a really_all_units;
426 if ( [[ ${+_sys_really_all_units} -eq 0 ]] || _cache_invalid SYS_REALLY_ALL_UNITS ) &&
427 ! _retrieve_cache SYS_REALLY_ALL_UNITS;
429 all_unit_files=( $(__systemctl list-unit-files | { while read a b; do echo "$a"; done; }) )
431 really_all_units=($_sys_all_units $all_unit_files)
432 _sys_really_all_units=(${(u)really_all_units})
433 _store_cache SYS_REALLY_ALL_UNITS _sys_really_all_units
437 _filter_units_by_property() {
438 local property=$1 value=$2 ; shift ; shift
439 local -a units ; units=($*)
441 for ((i=1; $i <= ${#units[*]}; i++)); do
442 # FIXME: "Failed to issue method call: Unknown unit" errors are ignored for
443 # now (related to DBUS_ERROR_UNKNOWN_OBJECT). in the future, we need to
444 # revert to calling 'systemctl show' once for all units, which is way
447 prop=${(f)"$(_call_program units "$service show --no-pager --property="$property" ${unit} 2>/dev/null")"}
448 if [[ "${prop}" = "$property=$value" ]]; then
454 _systemctl_active_units() {_sys_active_units=( $(__systemctl list-units | { while read a b; do echo "$a"; done; }) )}
455 _systemctl_inactive_units(){_sys_inactive_units=($(__systemctl list-units --all | { while read a b c d; do [[ $c == "inactive" ]] && echo "$a"; done; }) )}
456 _systemctl_failed_units() {_sys_failed_units=( $(__systemctl list-units --failed | { while read a b; do echo "$a"; done; }) )}
457 _systemctl_enabled_units() {_sys_enabled_units=( $(__systemctl list-unit-files | { while read a b; do [[ $b == "enabled" ]] && echo "$a"; done; }) )}
458 _systemctl_disabled_units(){_sys_disabled_units=($(__systemctl list-unit-files | { while read a b; do [[ $b == "disabled" ]] && echo "$a"; done; }) )}
459 _systemctl_masked_units() {_sys_masked_units=( $(__systemctl list-unit-files | { while read a b; do [[ $b == "masked" ]] && echo "$a"; done; }) )}
461 # Completion functions for ALL_UNITS
462 for fun in is-active is-failed is-enabled status show mask preset ; do
463 (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
465 _systemctl_really_all_units
466 compadd "$@" -a - _sys_really_all_units
470 # Completion functions for ENABLED_UNITS
471 for fun in disable reenable ; do
472 (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
474 _systemctl_enabled_units
475 compadd "$@" -a - _sys_enabled_units
479 # Completion functions for DISABLED_UNITS
480 (( $+functions[_systemctl_enable] )) || _systemctl_enable()
482 _systemctl_disabled_units
483 compadd "$@" -a - _sys_disabled_units
486 # Completion functions for FAILED_UNITS
487 (( $+functions[_systemctl_reset-failed] )) || _systemctl_reset-failed()
489 _systemctl_failed_units
490 compadd "$@" -a - _sys_failed_units || _message "no failed unit found"
493 # Completion functions for STARTABLE_UNITS
494 (( $+functions[_systemctl_start] )) || _systemctl_start()
496 _systemctl_inactive_units
497 compadd "$@" -a - _sys_inactive_units
500 # Completion functions for STOPPABLE_UNITS
501 for fun in stop kill try-restart condrestart ; do
502 (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
504 _systemctl_active_units
505 compadd "$@" - $( _filter_units_by_property CanStop yes \
506 ${_sys_active_units[*]} )
510 # Completion functions for ISOLATABLE_UNITS
511 (( $+functions[_systemctl_isolate] )) || _systemctl_isolate()
514 compadd "$@" - $( _filter_units_by_property AllowIsolate yes \
515 ${_sys_all_units[*]} )
518 # Completion functions for RELOADABLE_UNITS
519 for fun in reload reload-or-try-restart force-reload ; do
520 (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
522 _systemctl_active_units
523 compadd "$@" - $( _filter_units_by_property CanReload yes \
524 ${_sys_active_units[*]} )
528 # Completion functions for RESTARTABLE_UNITS
529 for fun in restart reload-or-restart ; do
530 (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
533 compadd "$@" - $( _filter_units_by_property CanStart yes \
534 ${_sys_all_units[*]} | while read line; do \
535 [[ "$line" =~ \.(device|snapshot|socket|timer)$ ]] || echo "$line"; \
540 # Completion functions for MASKED_UNITS
541 (( $+functions[_systemctl_unmask] )) || _systemctl_unmask()
543 _systemctl_masked_units
544 compadd "$@" -a - _sys_masked_units || _message "no masked unit found"
547 # Completion functions for JOBS
548 (( $+functions[_systemctl_cancel] )) || _systemctl_cancel()
550 compadd "$@" - $(__systemctl list-jobs \
551 | cut -d' ' -f1 2>/dev/null ) || _message "no job found"
554 # Completion functions for SNAPSHOTS
555 (( $+functions[_systemctl_delete] )) || _systemctl_delete()
557 compadd "$@" - $(__systemctl list-units --type snapshot --all \
558 | cut -d' ' -f1 2>/dev/null ) || _message "no snampshot found"
561 # Completion functions for ENVS
562 for fun in set-environment unset-environment ; do
563 (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
565 local fun=$0 ; fun=${fun##_systemctl_}
567 if [[ "${fun}" = "set-environment" ]]; then
571 compadd "$@" ${suf} - $(systemctl show-environment \
572 | while read line; do echo "${line%%\=}";done )
576 (( $+functions[_systemctl_link] )) || _systemctl_link() { _files }
578 # no systemctl completion for:
579 # [STANDALONE]='daemon-reexec daemon-reload default dump
580 # emergency exit halt kexec list-jobs list-units
581 # list-unit-files poweroff reboot rescue show-environment'
582 # [NAME]='snapshot load'
584 _systemctl_caching_policy()
589 # rebuild if cache is more than a day old
590 oldcache=( "$1"(mh+1) )
591 (( $#oldcache )) && return 0
593 _sysunits=($(__systemctl --all | cut -d' ' -f1))
595 if (( $#_sysunits )); then
596 for unit in $_sysunits; do
597 [[ "$unit" -nt "$1" ]] && return 0
605 local -a journal_fields
606 journal_fields=(MESSAGE{,_ID} PRIORITY CODE_{FILE,LINE,FUNC}
607 ERRNO SYSLOG_{FACILITY,IDENTIFIER,PID}
608 _{P,U,G}ID _COMM _EXE _CMDLINE
609 _AUDIT_{SESSION,LOGINUID}
610 _SYSTEMD_{CGROUP,SESSION,UNIT,OWNER_UID}
611 _SELINUX_CONTEXT _SOURCE_REALTIME_TIMESTAMP
612 _{BOOT,MACHINE}_ID _HOSTNAME _TRANSPORT
613 _KERNEL_{DEVICE,SUBSYSTEM}
614 _UDEV_{SYSNAME,DEVNODE,DEVLINK}
615 __CURSOR __{REALTIME,MONOTONIC}_TIMESTAMP)
616 _describe 'possible fields' journal_fields
621 cmd=("journalctl" "-F ${@[-1]}" "2>/dev/null" )
622 _fields=( ${(f)"$(_call_program fields $cmd[@])"} )
624 _describe 'possible values' _fields
628 _loginctl_all_sessions(){_sys_all_sessions=($(loginctl list-sessions | { while read a b; do echo "$a"; done; }) )}
629 _loginctl_all_users() {_sys_all_users=( $(loginctl list-users | { while read a b; do echo "$a"; done; }) )}
630 _loginctl_all_seats() {_sys_all_seats=( $(loginctl list-seats | { while read a b; do echo "$a"; done; }) )}
632 # Completion functions for SESSIONS
633 for fun in session-status show-session activate lock-session unlock-session terminate-session kill-session ; do
634 (( $+functions[_loginctl_$fun] )) || _loginctl_$fun()
636 _loginctl_all_sessions
637 compadd "$@" -a - _sys_all_sessions
641 # Completion functions for USERS
642 for fun in user-status show-user enable-linger disable-linger terminate-user kill-user ; do
643 (( $+functions[_loginctl_$fun] )) || _loginctl_$fun()
646 compadd "$@" -a - _sys_all_users
650 # Completion functions for SEATS
651 (( $+functions[_loginctl_seats] )) || _loginctl_seats()
654 compadd "$@" -a - _sys_all_seats
656 for fun in seat-status show-seat terminate-seat ; do
657 (( $+functions[_loginctl_$fun] )) || _loginctl_$fun()
661 # Completion functions for ATTACH
662 (( $+functions[_loginctl_attach] )) || _loginctl_attach()
666 _arguments -w -C -S -s \
667 ':seat:_loginctl_seats' \
671 # no loginctl completion for:
672 # [STANDALONE]='list-sessions list-users list-seats flush-devices'
674 (( $+functions[_loginctl_command] )) || _loginctl_command()
676 local -a _loginctl_cmds
678 "list-sessions:List sessions"
679 "session-status:Show session status"
680 "show-session:Show properties of one or more sessions"
681 "activate:Activate a session"
682 "lock-session:Screen lock one or more sessions"
683 "unlock-session:Screen unlock one or more sessions"
684 "terminate-session:Terminate one or more sessions"
685 "kill-session:Send signal to processes of a session"
686 "list-users:List users"
687 "user-status:Show user status"
688 "show-user:Show properties of one or more users"
689 "enable-linger:Enable linger state of one or more users"
690 "disable-linger:Disable linger state of one or more users"
691 "terminate-user:Terminate all sessions of one or more users"
692 "kill-user:Send signal to processes of a user"
693 "list-seats:List seats"
694 "seat-status:Show seat status"
695 "show-seat:Show properties of one or more seats"
696 "attach:Attach one or more devices to a seat"
697 "flush-devices:Flush all device associations"
698 "terminate-seat:Terminate all sessions on one or more seats"
701 if (( CURRENT == 1 )); then
702 _describe -t commands 'loginctl command' _loginctl_cmds || compadd "$@"
704 local curcontext="$curcontext"
706 cmd="${${_loginctl_cmds[(r)$words[1]:*]%%:*}}"
709 curcontext="${curcontext%:*:*}:loginctl-${cmd}:"
711 _call_function ret _loginctl_$cmd || _message 'no more arguments'
713 _message "unknown loginctl command: $words[1]"
719 _hostnamectl_command() {
720 local -a _hostnamectl_cmds
722 "status:Show current hostname settings"
723 "set-hostname:Set system hostname"
724 "set-icon-name:Set icon name for host"
726 if (( CURRENT == 1 )); then
727 _describe -t commands 'hostnamectl commands' _hostnamectl_cmds || compadd "$@"
729 local curcontext="$curcontext"
730 cmd="${${_hostnamectl_cmds[(r)$words[1]:*]%%:*}}"
732 [[ $cmd == status ]] && msg="no options" || msg="options for $cmd"
735 _message "unknown hostnamectl command: $words[1]"
740 _localectl_set-locale() {
741 local -a _confs _locales
743 _locales=( ${(f)"$(_call_program locales "$service" list-locales)"} )
744 _confs=( ${${(f)"$(_call_program confs "locale 2>/dev/null")"}%\=*} )
745 if [[ -prefix 1 *\= ]]; then
746 local conf=${PREFIX%%\=*}
748 _wanted locales expl "locales configs" \
749 _combination localeconfs confs=$conf locales "$@" -
751 compadd -S '=' $_confs
755 _localectl_set-keymap() {
757 _keymaps=( ${(f)"$(_call_program locales "$service" list-keymaps)"} )
758 if (( CURRENT <= 3 )); then
759 _describe keymaps _keymaps
761 _message "no more options"
765 _localectl_set-x11-keymap() {
766 if (( $+commands[pkg-config] )); then
767 local -a _file _layout _model _variant _options
769 _xorg_lst=${"$($commands[pkg-config] xkeyboard-config --variable=xkb_base)"}
770 _file=( ${(ps:\n\!:)"$(<$_xorg_lst/rules/xorg.lst)"} )
771 _layout=( ${${${(M)${(f)_file[1]}:# *}# }%% *} )
772 _model=( ${${${(M)${(f)_file[2]}:# *}# }%% *} )
773 _variant=( ${${${(M)${(f)_file[3]}:# *}# }%% *} )
774 _options=( ${${${(M)${(f)_file[4]}:# *}# }%% *} )
775 #_layout=( ${(f)"$( echo $_file[1] | awk '/^ / {print $1}' )"} )
776 #_model=( ${(f)"$(echo $_file[2] | awk '/^ / {print $1}')"} )
777 #_variant=( ${(f)"$(echo $_file[3] | awk '/^ / {print $1}')"} )
778 #_options=( ${(f)"$(echo ${_file[4]//:/\\:} | awk '/^ / {print $1}')"} )
781 2) _describe layouts _layout ;;
782 3) _describe models _model;;
783 4) _describe variants _variant;;
784 5) _describe options _options;;
785 *) _message "no more options"
791 _localectl_command() {
792 local -a _localectl_cmds
794 'status:Show current locale settings'
795 'set-locale:Set system locale'
796 'list-locales:Show known locales'
797 'set-keymap:Set virtual console keyboard mapping'
798 'list-keymaps:Show known virtual console keyboard mappings'
799 'set-x11-keymap:Set X11 keyboard mapping'
801 if (( CURRENT == 1 )); then
802 _describe -t commands 'localectl command' _localectl_cmds
804 local curcontext="$curcontext"
805 cmd="${${_localectl_cmds[(r)$words[1]:*]%%:*}}"
806 if (( $+functions[_localectl_$cmd] )); then
809 _message "no more options"
814 _timedatectl_set-timezone(){
816 _timezones=( ${(f)"$(_call_program timezones "${service}" list-timezones)"} )
817 compadd "$_timezones[@]"
820 _timedatectl_set-time(){
821 _message "YYYY-MM-DD HH:MM:SS"
824 _timedatectl_set-local-rtc(){
827 '0:Maintain RTC in universal time'
828 '1:Maintain RTC in local time'
830 _describe options _options
833 _timedatectl_set-ntp(){
836 '0:Disable NTP based network time configuration'
837 '1:Enable NTP based network time configuration'
839 _describe options _options
842 _timedatectl_command(){
843 local -a _timedatectl_cmds
845 'status:Show current time settings'
846 'set-time:Set system time'
847 'set-timezone:Set system timezone'
848 'list-timezones:Show known timezones'
849 'set-local-rtc:Control whether RTC is in local time'
850 'set-ntp:Control whether NTP is enabled'
852 if (( CURRENT == 1 )); then
853 _describe -t commands 'timedatectl command' _timedatectl_cmds
855 local curcontext="$curcontext"
856 cmd="${${_timedatectl_cmds[(r)$words[1]:*]%%:*}}"
858 if (( $+functions[_timedatectl_$cmd] )); then
861 _message "no more options"
864 _message "unknown timedatectl command: $words[1]"
868 _systemd-coredumpctl_command(){
869 local -a _systemd_coredumpctl_cmds
870 _systemd_coredumpctl_cmds=(
871 'list:List available coredumps'
872 'dump:Print coredump to std'
874 if (( CURRENT == 1 )); then
875 _describe -t commands 'systemd-coredumpctl command' _systemd_coredumpctl_cmds
877 local curcontext="$curcontext"
879 cmd="${${_systemd_coredumpctl_cmds[(r)$words[1]:*]%%:*}}"
881 dumps=( "${(f)$(_call_program dumps "systemd-coredumpctl list 2>/dev/null")}" )
882 if [[ -n "$dumps" ]]; then
883 compadd "${dumps[@]}"
885 _message "no coredumps"
888 _message "no more options"
897 '--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)' \
898 '--path=[The devpath of the device to query.]:sys files:_files -P /sys/ -W /sys' \
899 '--name=[The name of the device node or a symlink to query]:device files:_files -P /dev/ -W /dev' \
900 '--root[Print absolute paths in name or symlink query.]' \
901 '--attribute-walk[Print all sysfs properties of the specified device that can be used in udev rules to match the specified device]' \
902 '--export[Print output as key/value pairs.]' \
903 '--export-prefix=[Add a prefix to the key name of exported values.]:prefix' \
904 '--device-id-of-file=[Print major/minor numbers of the underlying device, where the file lives on.]:files:_udevadm_mounts' \
905 '--export-db[Export the content of the udev database.]' \
906 '--cleanup-db[Cleanup the udev database.]'
911 '--verbose[Print the list of devices which will be triggered.]' \
912 '--dry-run[Do not actually trigger the event.]' \
913 '--type=[Trigger a specific type of devices.]:types:(devices subsystems failed)' \
914 '--action=[Type of event to be triggered.]:actions:(add change remove)' \
915 '--subsystem-match=[Trigger events for devices which belong to a matching subsystem.]' \
916 '--subsystem-nomatch=[Do not trigger events for devices which belong to a matching subsystem.]' \
917 '--attr-match=attribute=[Trigger events for devices with a matching sysfs attribute.]' \
918 '--attr-nomatch=attribute=[Do not trigger events for devices with a matching sysfs attribute.]' \
919 '--property-match=[Trigger events for devices with a matching property value.]' \
920 '--tag-match=property[Trigger events for devices with a matching tag.]' \
921 '--sysname-match=[Trigger events for devices with a matching sys device name.]' \
922 '--parent-match=[Trigger events for all children of a given device.]'
927 '--timeout=[Maximum number of seconds to wait for the event queue to become empty.]' \
928 '--seq-start=[Wait only for events after the given sequence number.]' \
929 '--seq-end=[Wait only for events before the given sequence number.]' \
930 '--exit-if-exists=[Stop waiting if file exists.]:files:_files' \
931 '--quiet[Do not print any output, like the remaining queue entries when reaching the timeout.]' \
932 '--help[Print help text.]'
937 '--exit[Signal and wait for systemd-udevd to exit.]' \
938 '--log-priority=[Set the internal log level of systemd-udevd.]:priorities:(err info debug)' \
939 '--stop-exec-queue[Signal systemd-udevd to stop executing new events. Incoming events will be queued.]' \
940 '--start-exec-queue[Signal systemd-udevd to enable the execution of events.]' \
941 '--reload[Signal systemd-udevd to reload the rules files and other databases like the kernel module index.]' \
942 '--property=[Set a global property for all events.]' \
943 '--children-max=[Set the maximum number of events.]' \
944 '--timeout=[The maximum number of seconds to wait for a reply from systemd-udevd.]' \
945 '--help[Print help text.]'
950 '--kernel[Print the kernel uevents.]' \
951 '--udev[Print the udev event after the rule processing.]' \
952 '--property[Also print the properties of the event.]' \
953 '--subsystem-match=[Filter events by subsystem[/devtype].]' \
954 '--tag-match=[Filter events by property.]' \
955 '--help[Print help text.]'
960 '--action=[The action string.]:actions:(add change remove)' \
961 '--subsystem=[The subsystem string.]' \
962 '--help[Print help text.]' \
963 '*::devpath:_files -P /sys/ -W /sys'
966 _udevadm_test-builtin(){
967 if (( CURRENT == 2 )); then
969 '--help[Print help text]' \
970 '*::builtins:(blkid btrfs firmware hwdb input_id kmod path_id usb_id uaccess)'
971 elif (( CURRENT == 3 )); then
973 '--help[Print help text]' \
974 '*::syspath:_files -P /sys -W /sys'
977 '--help[Print help text]'
982 local dev_tmp dpath_tmp mp_tmp mline
984 tmp=( "${(@f)$(< /etc/mtab)}" )
985 dev_tmp=( "${(@)${(@)tmp%% *}:#none}" )
986 mp_tmp=( "${(@)${(@)tmp#* }%% *}" )
989 mp_tmp=("${(@q)mp_tmp//(#m)\\[0-7](#c3)/${(#)$(( 8#${MATCH[2,-1]} ))}}")
990 dpath_tmp=( "${(@Mq)dev_tmp:#/*}" )
991 dev_tmp=( "${(@q)dev_tmp:#/*}" )
994 'device-paths: device path:compadd -a dpath_tmp' \
995 'directories:mount point:compadd -a mp_tmp'
1000 local -a _udevadm_cmds
1002 'info:query sysfs or the udev database'
1003 'trigger:request events from the kernel'
1004 'settle:wait for the event queue to finish'
1005 'control:control the udev daemon'
1006 'monitor:listen to kernel and udev events'
1007 'test:test an event run'
1008 'test-builtin:test a built-in command'
1011 if ((CURRENT == 1)); then
1012 _describe -t commands 'udevadm commands' _udevadm_cmds
1014 local curcontext="$curcontext"
1015 cmd="${${_udevadm_cmds[(r)$words[1]:*]%%:*}}"
1017 if (( $+functions[_udevadm_$cmd] )); then
1020 _message "no options for $cmd"
1023 _message "no more options"
1030 #vim: set ft=zsh sw=4 ts=4 et