summaryrefslogtreecommitdiff
path: root/shell-completion/zsh/_systemctl.in
diff options
context:
space:
mode:
Diffstat (limited to 'shell-completion/zsh/_systemctl.in')
-rw-r--r--shell-completion/zsh/_systemctl.in18
1 files changed, 8 insertions, 10 deletions
diff --git a/shell-completion/zsh/_systemctl.in b/shell-completion/zsh/_systemctl.in
index 44c31b7833..03a1c930b0 100644
--- a/shell-completion/zsh/_systemctl.in
+++ b/shell-completion/zsh/_systemctl.in
@@ -123,15 +123,11 @@ _systemctl_really_all_units()
}
_filter_units_by_property() {
- local property=$1 value=$2 ; shift ; shift
- local -a units ; units=($*)
- local props
- for props in ${(ps:\n\n:)"$(_call_program units "$service show --no-pager --property="Id,$property" -- ${units} 2>/dev/null")"}; do
- props=(${(f)props})
- if [[ "${props[2]}" = "$property=$value" ]]; then
- echo -E - " ${props[1]#Id=}"
- fi
- done
+ local property=$1 value=$2; shift 2
+ local -a units; units=("${(q-)@}")
+ local -A props
+ props=(${(f)"$(_call_program units "$service $_sys_service_mgr show --no-pager --property=\"Id,$property\" -- ${units} 2>/dev/null")"})
+ echo -E - "${(@g:o:)${(k@)props[(Re)$property=$value]}#Id=}"
}
_systemctl_get_template_names() { echo -E - ${^${(M)${(f)"$(__systemctl list-unit-files)"}##*@.[^[:space:]]##}%%@.*}\@ }
@@ -351,8 +347,10 @@ _job_modes() {
_values -s , "${_modes[@]}"
}
+# Build arguments for "systemctl" to be used in completion.
local -a _modes; _modes=("--user" "--system")
-local _sys_service_mgr=${${words:*_modes}[(R)(${(j.|.)_modes})]:---system}
+# Use the last mode (they are exclusive and the last one is used).
+local _sys_service_mgr=${${words:*_modes}[(R)(${(j.|.)_modes})]}
_arguments -s \
{-h,--help}'[Show help]' \
'--version[Show package version]' \