]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - shell-completion/zsh/_systemctl.in
Merge pull request #11827 from keszybz/pkgconfig-variables
[thirdparty/systemd.git] / shell-completion / zsh / _systemctl.in
index 782d243131ab155ff0df48ba5b1a49b9ba61d469..590fc4960421ba4ca3284945825fbc80ae2dfe1c 100644 (file)
@@ -1,7 +1,7 @@
 #compdef systemctl
 # SPDX-License-Identifier: LGPL-2.1+
 
-(( $+functions[_systemctl_command] )) || _systemctl_command()
+(( $+functions[_systemctl_commands] )) || _systemctl_commands()
 {
   local -a _systemctl_cmds
   _systemctl_cmds=(
@@ -95,6 +95,7 @@
   fi
 }
 
+# @todo _systemd-run has a helper with the same name, so we must redefine
 __systemctl()
 {
   systemctl $_sys_service_mgr --full --no-legend --no-pager "$@" 2>/dev/null
@@ -102,6 +103,7 @@ __systemctl()
 
 
 # Fills the unit list
+(( $+functions[_systemctl_all_units] )) ||
 _systemctl_all_units()
 {
   if ( [[ ${+_sys_all_units} -eq 0 ]] || _cache_invalid SYS_ALL_UNITS$_sys_service_mgr ) ||
@@ -113,6 +115,7 @@ _systemctl_all_units()
 }
 
 # Fills the unit list including all file units
+(( $+functions[_systemctl_really_all_units] )) ||
 _systemctl_really_all_units()
 {
   local -a all_unit_files;
@@ -128,6 +131,7 @@ _systemctl_really_all_units()
   fi
 }
 
+(( $+functions[_filter_units_by_property] )) ||
 _filter_units_by_property() {
   local property=$1 value=$2; shift 2
   local -a units; units=("${(q-)@}")
@@ -136,16 +140,19 @@ _filter_units_by_property() {
   echo -E - "${(@g:o:)${(k@)props[(Re)$property=$value]}#Id=}"
 }
 
+(( $+functions[_systemctl_get_non_template_names] )) ||
 _systemctl_get_non_template_names() { echo -E - ${^${(R)${(f)"$(
     __systemctl $mode list-unit-files "$PREFIX*"
     __systemctl $mode list-units --all "$PREFIX*"
   )"}:#*@.*}%%[[:space:]]*} }
 
+(( $+functions[_systemctl_get_template_names] )) ||
 _systemctl_get_template_names() { echo -E - ${^${(M)${(f)"$(__systemctl list-unit-files "$PREFIX*" )"}##*@.[^[:space:]]##}%%@.*}\@ }
 
-
+(( $+functions[_systemctl_active_units] )) ||
 _systemctl_active_units()  {_sys_active_units=(  ${${(f)"$(__systemctl list-units "$PREFIX*" )"}%% *} )}
 
+(( $+functions[_systemctl_startable_units] )) ||
 _systemctl_startable_units(){
   _sys_startable_units=( $( _filter_units_by_property ActiveState inactive $(
     _filter_units_by_property CanStart yes ${${${(f)"$(
@@ -155,6 +162,7 @@ _systemctl_startable_units(){
   )) )
 }
 
+(( $+functions[_systemctl_restartable_units] )) ||
 _systemctl_restartable_units(){
   _sys_restartable_units=( $( _filter_units_by_property CanStart yes ${${${(f)"$(
     __systemctl $mode list-unit-files --state enabled,disabled,static "$PREFIX*"
@@ -162,7 +170,10 @@ _systemctl_restartable_units(){
   )"}:#*@.*}%%[[:space:]]*} ) )
 }
 
+(( $+functions[_systemctl_failed_units] )) ||
 _systemctl_failed_units()  {_sys_failed_units=( ${${(f)"$(__systemctl list-units --state=failed "$PREFIX*" )"}%% *} ) }
+
+(( $+functions[_systemctl_unit_state] )) ||
 _systemctl_unit_state() { typeset -gA _sys_unit_state; _sys_unit_state=( $(__systemctl list-unit-files "$PREFIX*" ) ) }
 
 local fun
@@ -316,6 +327,7 @@ done
 #                  emergency exit halt kexec list-jobs list-units
 #                  list-unit-files poweroff reboot rescue show-environment'
 
+(( $+functions[_systemctl_caching_policy] )) ||
 _systemctl_caching_policy()
 {
   local _sysunits
@@ -336,19 +348,22 @@ _systemctl_caching_policy()
   return 1
 }
 
-_unit_states() {
+(( $+functions[_systemctl_unit_states] )) ||
+_systemctl_unit_states() {
     local -a _states
     _states=("${(fo)$(__systemctl --state=help)}")
     _values -s , "${_states[@]}"
 }
 
-_unit_types() {
+(( $+functions[_systemctl_unit_types] )) ||
+_systemctl_unit_types() {
     local -a _types
     _types=("${(fo)$(__systemctl -t help)}")
     _values -s , "${_types[@]}"
 }
 
-_unit_properties() {
+(( $+functions[_systemctl_unit_properties] )) ||
+_systemctl_unit_properties() {
   if ( [[ ${+_sys_all_properties} -eq 0 ]] || _cache_invalid SYS_ALL_PROPERTIES$_sys_service_mgr ) ||
     ! _retrieve_cache SYS_ALL_PROPERTIES$_sys_service_mgr;
   then
@@ -358,7 +373,8 @@ _unit_properties() {
   _values -s , "${_sys_all_properties[@]}"
 }
 
-_job_modes() {
+(( $+functions[_systemctl_job_modes] )) ||
+_systemctl_job_modes() {
     local -a _modes
     _modes=(fail replace replace-irreversibly isolate ignore-dependencies ignore-requirements flush)
     _values -s , "${_modes[@]}"
@@ -371,10 +387,10 @@ local _sys_service_mgr=${${words:*_modes}[(R)(${(j.|.)_modes})]}
 _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' \
+    {-t+,--type=}'[List only units of a particular type]:unit type:_systemctl_unit_types' \
+    '--state=[Display units in the specified state]:unit state:_systemctl_unit_states' \
+    '--job-mode=[Specify how to deal with other jobs]:mode:_systemctl_job_modes' \
+    {-p+,--property=}'[Show only properties by specific name]:unit property:_systemctl_unit_properties' \
     {-a,--all}'[Show all units/properties, including dead/empty ones]' \
     '--reverse[Show reverse dependencies]' \
     '--after[Show units ordered after]' \
@@ -404,4 +420,4 @@ _arguments -s \
     '--firmware-setup[Tell the firmware to show the setup menu on next boot]' \
     '--plain[When used with list-dependencies, print output as a list]' \
     '--failed[Show failed units]' \
-    '*::systemctl command:_systemctl_command'
+    '*::systemctl command:_systemctl_commands'