_systemctl.in revision 840b2c0e77911bef3056f358b8d16a3253e4ab70
52ea316008e2581c8113441c9c341e5c65225f6anilgun#compdef systemctl
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun(( $+functions[_systemctl_command] )) || _systemctl_command()
52ea316008e2581c8113441c9c341e5c65225f6anilgun{
52ea316008e2581c8113441c9c341e5c65225f6anilgun local -a _systemctl_cmds
52ea316008e2581c8113441c9c341e5c65225f6anilgun _systemctl_cmds=(
52ea316008e2581c8113441c9c341e5c65225f6anilgun "list-sockets:List sockets"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "list-timers:List timers"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "list-units:List units"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "start:Start (activate) one or more units"
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen "stop:Stop (deactivate) one or more units"
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen "reload:Reload one or more units"
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen "restart:Start or restart one or more units"
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen "condrestart:Restart one or more units if active"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "try-restart:Restart one or more units if active"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "reload-or-restart:Reload one or more units if possible, otherwise start or restart"
d229f940abfb2490dee17979e9a5ff31b7012eb5rbowen "force-reload:Reload one or more units if possible, otherwise restart if active"
3f08db06526d6901aa08c110b5bc7dde6bc39905nd "hibernate:Hibernate the system"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "hybrid-sleep:Hibernate and suspend the system"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "reload-or-try-restart:Reload one or more units if possible, otherwise restart if active"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "isolate:Start one unit and stop all others"
3f08db06526d6901aa08c110b5bc7dde6bc39905nd "kill:Send signal to processes of a unit"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "is-active:Check whether units are active"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "is-failed:Check whether units are failed"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "status:Show runtime status of one or more units"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "show:Show properties of one or more units/jobs or the manager"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "cat:Show the source unit files and drop-ins"
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung "reset-failed:Reset failed state for all, one, or more units"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "list-unit-files:List installed unit files"
51b60896224b408a35684bd6ec0fafe5e4abe322rbowen "enable:Enable one or more unit files"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "disable:Disable one or more unit files"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "reenable:Reenable one or more unit files"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "preset:Enable/disable one or more unit files based on preset configuration"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "set-default:Set the default target"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "get-default:Query the default target"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "edit:Edit one or more unit files"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "is-system-running:Query overall status of the system"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "help:Show documentation for specified units"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "list-dependencies:Show unit dependency tree"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "mask:Mask one or more units"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "unmask:Unmask one or more units"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "link:Link one or more units files into the search path"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "is-enabled:Check whether unit files are enabled"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "list-jobs:List jobs"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "cancel:Cancel all, one, or more jobs"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "snapshot:Create a snapshot"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "delete:Remove one or more snapshots"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "show-environment:Dump environment"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "set-environment:Set one or more environment variables"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "unset-environment:Unset one or more environment variables"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "daemon-reload:Reload systemd manager configuration"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "daemon-reexec:Reexecute systemd manager"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "default:Enter system default mode"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "rescue:Enter system rescue mode"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "emergency:Enter system emergency mode"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "halt:Shut down and halt the system"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "suspend:Suspend the system"
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh "poweroff:Shut down and power-off the system"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "reboot:Shut down and reboot the system"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "kexec:Shut down and reboot the system with kexec"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "exit:Ask for user instance termination"
52ea316008e2581c8113441c9c341e5c65225f6anilgun "switch-root:Change root directory"
52ea316008e2581c8113441c9c341e5c65225f6anilgun )
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun if (( CURRENT == 1 )); then
52ea316008e2581c8113441c9c341e5c65225f6anilgun _describe -t commands 'systemctl command' _systemctl_cmds || compadd "$@"
52ea316008e2581c8113441c9c341e5c65225f6anilgun else
52ea316008e2581c8113441c9c341e5c65225f6anilgun local curcontext="$curcontext" expl
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun cmd="${${_systemctl_cmds[(r)$words[1]:*]%%:*}}"
52ea316008e2581c8113441c9c341e5c65225f6anilgun # Deal with any aliases
52ea316008e2581c8113441c9c341e5c65225f6anilgun case $cmd in
52ea316008e2581c8113441c9c341e5c65225f6anilgun condrestart) cmd="try-restart";;
52ea316008e2581c8113441c9c341e5c65225f6anilgun force-reload) cmd="reload-or-try-restart";;
52ea316008e2581c8113441c9c341e5c65225f6anilgun esac
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun if (( $#cmd )); then
52ea316008e2581c8113441c9c341e5c65225f6anilgun curcontext="${curcontext%:*:*}:systemctl-${cmd}:"
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun local update_policy
52ea316008e2581c8113441c9c341e5c65225f6anilgun zstyle -s ":completion:${curcontext}:" cache-policy update_policy
52ea316008e2581c8113441c9c341e5c65225f6anilgun if [[ -z "$update_policy" ]]; then
52ea316008e2581c8113441c9c341e5c65225f6anilgun zstyle ":completion:${curcontext}:" cache-policy _systemctl_caching_policy
52ea316008e2581c8113441c9c341e5c65225f6anilgun fi
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun _call_function ret _systemctl_$cmd || _message 'no more arguments'
52ea316008e2581c8113441c9c341e5c65225f6anilgun else
52ea316008e2581c8113441c9c341e5c65225f6anilgun _message "unknown systemctl command: $words[1]"
52ea316008e2581c8113441c9c341e5c65225f6anilgun fi
52ea316008e2581c8113441c9c341e5c65225f6anilgun return ret
52ea316008e2581c8113441c9c341e5c65225f6anilgun fi
52ea316008e2581c8113441c9c341e5c65225f6anilgun}
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun__systemctl()
52ea316008e2581c8113441c9c341e5c65225f6anilgun{
52ea316008e2581c8113441c9c341e5c65225f6anilgun systemctl $_sys_service_mgr --full --no-legend --no-pager "$@"
52ea316008e2581c8113441c9c341e5c65225f6anilgun}
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun# Fills the unit list
52ea316008e2581c8113441c9c341e5c65225f6anilgun_systemctl_all_units()
52ea316008e2581c8113441c9c341e5c65225f6anilgun{
52ea316008e2581c8113441c9c341e5c65225f6anilgun if ( [[ ${+_sys_all_units} -eq 0 ]] || _cache_invalid SYS_ALL_UNITS ) &&
52ea316008e2581c8113441c9c341e5c65225f6anilgun ! _retrieve_cache SYS_ALL_UNITS;
52ea316008e2581c8113441c9c341e5c65225f6anilgun then
52ea316008e2581c8113441c9c341e5c65225f6anilgun _sys_all_units=( ${${(f)"$(__systemctl list-units --all)"}%% *} )
52ea316008e2581c8113441c9c341e5c65225f6anilgun _store_cache SYS_ALL_UNITS _sys_all_units
52ea316008e2581c8113441c9c341e5c65225f6anilgun fi
52ea316008e2581c8113441c9c341e5c65225f6anilgun}
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun# Fills the unit list including all file units
52ea316008e2581c8113441c9c341e5c65225f6anilgun_systemctl_really_all_units()
52ea316008e2581c8113441c9c341e5c65225f6anilgun{
52ea316008e2581c8113441c9c341e5c65225f6anilgun local -a all_unit_files;
52ea316008e2581c8113441c9c341e5c65225f6anilgun local -a really_all_units;
52ea316008e2581c8113441c9c341e5c65225f6anilgun if ( [[ ${+_sys_really_all_units} -eq 0 ]] || _cache_invalid SYS_REALLY_ALL_UNITS ) &&
52ea316008e2581c8113441c9c341e5c65225f6anilgun ! _retrieve_cache SYS_REALLY_ALL_UNITS;
52ea316008e2581c8113441c9c341e5c65225f6anilgun then
52ea316008e2581c8113441c9c341e5c65225f6anilgun all_unit_files=( ${${(f)"$(__systemctl list-unit-files)"}%% *} )
52ea316008e2581c8113441c9c341e5c65225f6anilgun _systemctl_all_units
52ea316008e2581c8113441c9c341e5c65225f6anilgun really_all_units=($_sys_all_units $all_unit_files)
52ea316008e2581c8113441c9c341e5c65225f6anilgun _sys_really_all_units=(${(u)really_all_units})
52ea316008e2581c8113441c9c341e5c65225f6anilgun _store_cache SYS_REALLY_ALL_UNITS _sys_really_all_units
52ea316008e2581c8113441c9c341e5c65225f6anilgun fi
52ea316008e2581c8113441c9c341e5c65225f6anilgun}
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun_filter_units_by_property() {
52ea316008e2581c8113441c9c341e5c65225f6anilgun local property=$1 value=$2 ; shift ; shift
52ea316008e2581c8113441c9c341e5c65225f6anilgun local -a units ; units=($*)
52ea316008e2581c8113441c9c341e5c65225f6anilgun local props
52ea316008e2581c8113441c9c341e5c65225f6anilgun for props in ${(ps:\n\n:)"$(_call_program units "$service show --no-pager --property="Id,$property" -- ${units} 2>/dev/null")"}; do
52ea316008e2581c8113441c9c341e5c65225f6anilgun props=(${(f)props})
52ea316008e2581c8113441c9c341e5c65225f6anilgun if [[ "${props[2]}" = "$property=$value" ]]; then
52ea316008e2581c8113441c9c341e5c65225f6anilgun echo -E - " ${props[1]#Id=}"
52ea316008e2581c8113441c9c341e5c65225f6anilgun fi
52ea316008e2581c8113441c9c341e5c65225f6anilgun done
52ea316008e2581c8113441c9c341e5c65225f6anilgun}
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun_systemctl_get_template_names() { echo -E - ${^${(M)${(f)"$(__systemctl list-unit-files)"}##*@.[^[:space:]]##}%%@.*}\@ }
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun_systemctl_active_units() {_sys_active_units=( ${${(f)"$(__systemctl list-units)"}%% *} )}
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun_systemctl_startable_units(){
52ea316008e2581c8113441c9c341e5c65225f6anilgun _sys_startable_units=( $( _filter_units_by_property ActiveState inactive $(
52ea316008e2581c8113441c9c341e5c65225f6anilgun _filter_units_by_property CanStart yes $(
52ea316008e2581c8113441c9c341e5c65225f6anilgun __systemctl $mode list-unit-files --state enabled,disabled,static | \
52ea316008e2581c8113441c9c341e5c65225f6anilgun { while read -r a b; do [[ $a =~ @\. ]] || echo -E - " $a"; done; }
52ea316008e2581c8113441c9c341e5c65225f6anilgun __systemctl $mode list-units --state inactive,failed | \
52ea316008e2581c8113441c9c341e5c65225f6anilgun { while read -r a b; do echo -E - " $a"; done; } )) ) )
52ea316008e2581c8113441c9c341e5c65225f6anilgun}
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun_systemctl_restartable_units(){
52ea316008e2581c8113441c9c341e5c65225f6anilgun _sys_restartable_units=( $(_filter_units_by_property CanStart yes $(
52ea316008e2581c8113441c9c341e5c65225f6anilgun __systemctl $mode list-unit-files --state enabled,disabled,static | \
52ea316008e2581c8113441c9c341e5c65225f6anilgun { while read -r a b; do [[ $a =~ @\. ]] || echo -E - " $a"; done; }
52ea316008e2581c8113441c9c341e5c65225f6anilgun __systemctl $mode list-units | \
52ea316008e2581c8113441c9c341e5c65225f6anilgun { while read -r a b; do echo -E - " $a"; done; } )) )
52ea316008e2581c8113441c9c341e5c65225f6anilgun}
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun_systemctl_failed_units() {_sys_failed_units=( ${${(f)"$(__systemctl list-units --failed)"}%% *} ) }
52ea316008e2581c8113441c9c341e5c65225f6anilgun_systemctl_unit_state() { typeset -gA _sys_unit_state; _sys_unit_state=( $(__systemctl list-unit-files) ) }
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgunlocal fun
52ea316008e2581c8113441c9c341e5c65225f6anilgun# Completion functions for ALL_UNITS
52ea316008e2581c8113441c9c341e5c65225f6anilgunfor fun in is-active is-failed is-enabled status show cat mask preset help list-dependencies edit ; do
52ea316008e2581c8113441c9c341e5c65225f6anilgun (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
52ea316008e2581c8113441c9c341e5c65225f6anilgun {
52ea316008e2581c8113441c9c341e5c65225f6anilgun _systemctl_really_all_units
52ea316008e2581c8113441c9c341e5c65225f6anilgun _wanted systemd-units expl unit \
52ea316008e2581c8113441c9c341e5c65225f6anilgun compadd "$@" -a - _sys_really_all_units
52ea316008e2581c8113441c9c341e5c65225f6anilgun }
52ea316008e2581c8113441c9c341e5c65225f6anilgundone
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun# Completion functions for ENABLED_UNITS
52ea316008e2581c8113441c9c341e5c65225f6anilgun(( $+functions[_systemctl_disable] )) || _systemctl_disable()
52ea316008e2581c8113441c9c341e5c65225f6anilgun{
52ea316008e2581c8113441c9c341e5c65225f6anilgun local _sys_unit_state; _systemctl_unit_state
52ea316008e2581c8113441c9c341e5c65225f6anilgun _wanted systemd-units expl 'enabled unit' \
52ea316008e2581c8113441c9c341e5c65225f6anilgun compadd "$@" - ${(k)_sys_unit_state[(R)enabled]}
52ea316008e2581c8113441c9c341e5c65225f6anilgun}
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun(( $+functions[_systemctl_reenable] )) || _systemctl_reenable()
52ea316008e2581c8113441c9c341e5c65225f6anilgun{
52ea316008e2581c8113441c9c341e5c65225f6anilgun local _sys_unit_state; _systemctl_unit_state
52ea316008e2581c8113441c9c341e5c65225f6anilgun _wanted systemd-units expl 'enabled/disabled unit' \
52ea316008e2581c8113441c9c341e5c65225f6anilgun compadd "$@" - ${(k)_sys_unit_state[(R)(enabled|disabled)]} $(_systemctl_get_template_names)
52ea316008e2581c8113441c9c341e5c65225f6anilgun}
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun# Completion functions for DISABLED_UNITS
52ea316008e2581c8113441c9c341e5c65225f6anilgun(( $+functions[_systemctl_enable] )) || _systemctl_enable()
52ea316008e2581c8113441c9c341e5c65225f6anilgun{
52ea316008e2581c8113441c9c341e5c65225f6anilgun local _sys_unit_state; _systemctl_unit_state
52ea316008e2581c8113441c9c341e5c65225f6anilgun _wanted systemd-units expl 'disabled unit' \
52ea316008e2581c8113441c9c341e5c65225f6anilgun compadd "$@" - ${(k)_sys_unit_state[(R)disabled]} $(_systemctl_get_template_names)
52ea316008e2581c8113441c9c341e5c65225f6anilgun}
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun# Completion functions for FAILED_UNITS
52ea316008e2581c8113441c9c341e5c65225f6anilgun(( $+functions[_systemctl_reset-failed] )) || _systemctl_reset-failed()
52ea316008e2581c8113441c9c341e5c65225f6anilgun{
52ea316008e2581c8113441c9c341e5c65225f6anilgun local _sys_failed_units; _systemctl_failed_units
52ea316008e2581c8113441c9c341e5c65225f6anilgun _wanted systemd-units expl 'failed unit' \
52ea316008e2581c8113441c9c341e5c65225f6anilgun compadd "$@" -a - _sys_failed_units || _message "no failed unit found"
52ea316008e2581c8113441c9c341e5c65225f6anilgun}
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun# Completion functions for STARTABLE_UNITS
52ea316008e2581c8113441c9c341e5c65225f6anilgun(( $+functions[_systemctl_start] )) || _systemctl_start()
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung{
727872d18412fc021f03969b8641810d8896820bhumbedooh local _sys_startable_units; _systemctl_startable_units
0d0ba3a410038e179b695446bb149cce6264e0abnd _wanted systemd-units expl 'startable unit' \
727872d18412fc021f03969b8641810d8896820bhumbedooh compadd "$@" - ${_sys_startable_units[*]} $(_systemctl_get_template_names)
727872d18412fc021f03969b8641810d8896820bhumbedooh}
0d0ba3a410038e179b695446bb149cce6264e0abnd
727872d18412fc021f03969b8641810d8896820bhumbedooh# Completion functions for STOPPABLE_UNITS
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedoohfor fun in stop kill try-restart condrestart ; do
727872d18412fc021f03969b8641810d8896820bhumbedooh (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
0d0ba3a410038e179b695446bb149cce6264e0abnd {
0d0ba3a410038e179b695446bb149cce6264e0abnd local _sys_active_units; _systemctl_active_units
0d0ba3a410038e179b695446bb149cce6264e0abnd _wanted systemd-units expl 'stoppable unit' \
727872d18412fc021f03969b8641810d8896820bhumbedooh compadd "$@" - $( _filter_units_by_property CanStop yes \
0d0ba3a410038e179b695446bb149cce6264e0abnd ${_sys_active_units[*]} )
0d0ba3a410038e179b695446bb149cce6264e0abnd }
0d0ba3a410038e179b695446bb149cce6264e0abnddone
727872d18412fc021f03969b8641810d8896820bhumbedooh
0d0ba3a410038e179b695446bb149cce6264e0abnd# Completion functions for ISOLATABLE_UNITS
0d0ba3a410038e179b695446bb149cce6264e0abnd(( $+functions[_systemctl_isolate] )) || _systemctl_isolate()
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh{
5effc8b39fae5cd169d17f342bfc265705840014rbowen _systemctl_all_units
d229f940abfb2490dee17979e9a5ff31b7012eb5rbowen _wanted systemd-units expl 'isolatable unit' \
0d0ba3a410038e179b695446bb149cce6264e0abnd compadd "$@" - $( _filter_units_by_property AllowIsolate yes \
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd ${_sys_all_units[*]} )
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd}
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd
52ea316008e2581c8113441c9c341e5c65225f6anilgun# Completion functions for RELOADABLE_UNITS
for fun in reload reload-or-try-restart force-reload ; do
(( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
{
local _sys_active_units; _systemctl_active_units
_wanted systemd-units expl 'reloadable unit' \
compadd "$@" - $( _filter_units_by_property CanReload yes \
${_sys_active_units[*]} )
}
done
# Completion functions for RESTARTABLE_UNITS
for fun in restart reload-or-restart ; do
(( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
{
local _sys_restartable_units; _systemctl_restartable_units
_wanted systemd-units expl 'restartable unit' \
compadd "$@" - ${_sys_restartable_units[*]} $(_systemctl_get_template_names)
}
done
# Completion functions for MASKED_UNITS
(( $+functions[_systemctl_unmask] )) || _systemctl_unmask()
{
local _sys_unit_state; _systemctl_unit_state
_wanted systemd-units expl 'masked unit' \
compadd "$@" - ${(k)_sys_unit_state[(R)masked]} || _message "no masked units found"
}
# Completion functions for JOBS
(( $+functions[_systemctl_cancel] )) || _systemctl_cancel()
{
_wanted systemd-jobs expl job \
compadd "$@" - ${${(f)"$(__systemctl list-jobs)"}%% *} ||
_message "no jobs found"
}
# Completion functions for SNAPSHOTS
(( $+functions[_systemctl_delete] )) || _systemctl_delete()
{
_wanted systemd-snapshots expl snapshot \
compadd "$@" - ${${(f)"$(__systemctl list-units --type snapshot --all)"}%% *} ||
_message "no snapshots found"
}
# Completion functions for TARGETS
(( $+functions[_systemctl_set-default] )) || _systemctl_set-default()
{
_wanted systemd-targets expl target \
compadd "$@" - ${${(f)"$(__systemctl list-unit-files --type target --all)"}%% *} ||
_message "no targets found"
}
# Completion functions for ENVS
for fun in set-environment unset-environment ; do
(( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
{
local fun=$0 ; fun=${fun##_systemctl_}
local suf
if [[ "${fun}" = "set-environment" ]]; then
suf='-S='
fi
_wanted systemd-environment expl 'environment variable' \
compadd "$@" ${suf} - ${${(f)"$(systemctl show-environment)"}%%=*}
}
done
(( $+functions[_systemctl_link] )) || _systemctl_link() {
_sd_unit_files
}
(( $+functions[_systemctl_switch-root] )) || _systemctl_switch-root() {
_files
}
# no systemctl completion for:
# [STANDALONE]='daemon-reexec daemon-reload default
# emergency exit halt kexec list-jobs list-units
# list-unit-files poweroff reboot rescue show-environment'
# [NAME]='snapshot'
_systemctl_caching_policy()
{
local _sysunits
local -a oldcache
# rebuild if cache is more than a day old
oldcache=( "$1"(mh+1) )
(( $#oldcache )) && return 0
_sysunits=(${${(f)"$(__systemctl --all)"}%% *})
if (( $#_sysunits )); then
for unit in $_sysunits; do
[[ "$unit" -nt "$1" ]] && return 0
done
fi
return 1
}
_unit_states() {
local -a _states
_states=("${(fo)$(__systemctl --state=help)}")
_values -s , "${_states[@]}"
}
_unit_types() {
local -a _types
_types=("${(fo)$(__systemctl -t help)}")
_values -s , "${_types[@]}"
}
_unit_properties() {
if ( [[ ${+_sys_all_properties} -eq 0 ]] || _cache_invalid SYS_ALL_PROPERTIES ) &&
! _retrieve_cache SYS_ALL_PROPERTIES;
then
_sys_all_properties=( ${${(M)${(f)"$(__systemctl show --all;
@rootlibexecdir@/systemd --dump-configuration-items)"}##[[:alnum:]]##=*}%%=*}
)
_store_cache SYS_ALL_PROPRTIES _sys_all_properties
fi
_values -s , "${_sys_all_properties[@]}"
}
_job_modes() {
local -a _modes
_modes=(fail replace replace-irreversibly isolate ignore-dependencies ignore-requirements flush)
_values -s , "${_modes[@]}"
}
local -a _modes; _modes=("--user" "--system")
local _sys_service_mgr=${${words:*_modes}[(R)(${(j.|.)_modes})]:---system}
_arguments -s \
{-h,--help}'[Show help]' \
'--version[Show package version]' \
{-t+,--type=}'[List only units of a particular type]:unit type:_unit_types' \
'--state=[Display units in the specified state]:unit state:_unit_states' \
'--job-mode=[Specify how to deal with other jobs]:mode:_job_modes' \
{-p+,--property=}'[Show only properties by specific name]:unit property:_unit_properties' \
{-a,--all}'[Show all units/properties, including dead/empty ones]' \
'--reverse[Show reverse dependencies]' \
'--after[Show units ordered after]' \
'--before[Show units ordered before]' \
'--failed[Show only failed units]' \
{-l,--full}"[Don't ellipsize unit names on output]" \
'--show-types[When showing sockets, show socket type]' \
{-i,--ignore-inhibitors}'[When executing a job, ignore jobs dependencies]' \
{-q,--quiet}'[Suppress output]' \
'--no-block[Do not wait until operation finished]' \
'--no-legend[Do not print a legend, i.e. the column headers and the footer with hints]' \
'--no-pager[Do not pipe output into a pager]' \
'--system[Connect to system manager]' \
'--user[Connect to user service manager]' \
"--no-wall[Don't send wall message before halt/power-off/reboot]" \
'--global[Enable/disable unit files globally]' \
"--no-reload[When enabling/disabling unit files, don't reload daemon configuration]" \
'--no-ask-password[Do not ask for system passwords]' \
'--kill-who=[Who to send signal to]:killwho:(main control all)' \
{-s+,--signal=}'[Which signal to send]:signal:_signals' \
{-f,--force}'[When enabling unit files, override existing symlinks. When shutting down, execute action immediately]' \
'--root=[Enable unit files in the specified root directory]:directory:_directories' \
'--runtime[Enable unit files only temporarily until next reboot]' \
{-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \
{-P,--privileged}'[Acquire privileges before execution]' \
{-n+,--lines=}'[Journal entries to show]:number of entries' \
{-o+,--output=}'[Change journal output mode]:modes:_sd_outputmodes' \
'--firmware-setup[Tell the firmware to show the setup menu on next boot]' \
'--plain[When used with list-dependencies, print output as a list]' \
'*::systemctl command:_systemctl_command'