|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
From cd2c48a58a8cdbaab89c0227355a47ef27a5be53 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
From: Eric Cook <llua@gmx.com>
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
Date: Mon, 18 May 2015 03:19:59 -0400
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
Subject: [PATCH] zsh-completion: removing more pointless forks
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
I seem to have forgot about _systemctl_active_units().
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
(cherry picked from commit 2103d29d89f32546f95b9ec019be0ea06714c8c2)
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
shell-completion/zsh/_systemctl.in | 30 ++++++++++++++----------------
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
1 file changed, 14 insertions(+), 16 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
diff --git a/shell-completion/zsh/_systemctl.in b/shell-completion/zsh/_systemctl.in
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
index e95b7d3af0..2a3e21bf17 100644
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
--- a/shell-completion/zsh/_systemctl.in
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+++ b/shell-completion/zsh/_systemctl.in
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
@@ -105,7 +105,7 @@ _systemctl_all_units()
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
if ( [[ ${+_sys_all_units} -eq 0 ]] || _cache_invalid SYS_ALL_UNITS ) &&
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
! _retrieve_cache SYS_ALL_UNITS;
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
then
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- _sys_all_units=( $(__systemctl list-units --all | { while read -r a b; do echo -E - " $a"; done; }) )
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ _sys_all_units=( ${${(f)"$(__systemctl list-units --all)"}%% *} )
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
_store_cache SYS_ALL_UNITS _sys_all_units
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
fi
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
@@ -118,7 +118,7 @@ _systemctl_really_all_units()
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
if ( [[ ${+_sys_really_all_units} -eq 0 ]] || _cache_invalid SYS_REALLY_ALL_UNITS ) &&
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
! _retrieve_cache SYS_REALLY_ALL_UNITS;
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
then
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- all_unit_files=( $(__systemctl list-unit-files | { while read -r a b; do echo -E - " $a"; done; }) )
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ all_unit_files=( ${${(f)"$(__systemctl list-unit-files)"}%% *} )
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
_systemctl_all_units
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
really_all_units=($_sys_all_units $all_unit_files)
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
_sys_really_all_units=(${(u)really_all_units})
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
@@ -146,7 +146,7 @@ _filter_units_by_property() {
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
_systemctl_get_template_names() { echo -E - ${^${(M)${(f)"$(__systemctl list-unit-files)"}##*@.[^[:space:]]##}%%@.*}\@ }
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
-_systemctl_active_units() {_sys_active_units=( $(__systemctl list-units | { while read -r a b; do echo -E - " $a"; done; }) )}
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+_systemctl_active_units() {_sys_active_units=( ${${(f)"$(__systemctl list-units)"}%% *} )}
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
_systemctl_startable_units(){
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
_sys_startable_units=( $( _filter_units_by_property ActiveState inactive $(
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
@@ -259,22 +259,22 @@ done
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
# Completion functions for JOBS
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
(( $+functions[_systemctl_cancel] )) || _systemctl_cancel()
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
{
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- compadd "$@" - $(__systemctl list-jobs \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- | cut -d' ' -f1 2>/dev/null ) || _message "no jobs found"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ compadd "$@" - ${${(f)"$(__systemctl list-jobs)"}%% *} ||
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ _message "no jobs found"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
# Completion functions for SNAPSHOTS
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
(( $+functions[_systemctl_delete] )) || _systemctl_delete()
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
{
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- compadd "$@" - $(__systemctl list-units --type snapshot --all \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- | cut -d' ' -f1 2>/dev/null ) || _message "no snapshots found"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ compadd "$@" - ${${(f)"$(__systemctl list-units --type snapshot --all)"}%% *} ||
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ _message "no snapshots found"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
# Completion functions for TARGETS
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
(( $+functions[_systemctl_set-default] )) || _systemctl_set-default()
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
{
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- compadd "$@" - $(__systemctl list-unit-files --type target --all \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- | cut -d' ' -f1 2>/dev/null ) || _message "no targets found"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ compadd "$@" - ${${(f)"$(__systemctl list-unit-files --type target --all)"}%% *} ||
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ _message "no targets found"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
# Completion functions for ENVS
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
@@ -287,8 +287,7 @@ for fun in set-environment unset-environment ; do
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
suf='-S='
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
fi
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- compadd "$@" ${suf} - $(systemctl show-environment \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- | while read line; do echo " ${line%%\=}";done )
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ compadd "$@" ${suf} - ${${(f)"$(systemctl show-environment)"}%%=*}
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
done
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
@@ -315,7 +314,7 @@ _systemctl_caching_policy()
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
oldcache=( "$1"(mh+1) )
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
(( $#oldcache )) && return 0
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- _sysunits=($(__systemctl --all | cut -d' ' -f1))
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ _sysunits=(${${(f)"$(__systemctl --all)"}%% *})
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
if (( $#_sysunits )); then
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
for unit in $_sysunits; do
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
@@ -342,10 +341,9 @@ _unit_properties() {
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
if ( [[ ${+_sys_all_properties} -eq 0 ]] || _cache_invalid SYS_ALL_PROPERTIES ) &&
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
! _retrieve_cache SYS_ALL_PROPERTIES;
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
then
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- _sys_all_properties=( $( {__systemctl show --all;
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- @rootlibexecdir@/systemd --dump-configuration-items; } | {
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- while IFS='=' read -r a b; do [ -n "$b" ] && echo "$a"; done
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- }) )
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ _sys_all_properties=( ${${(M)${(f)"$(__systemctl show --all;
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ @rootlibexecdir@/systemd --dump-configuration-items)"}##[[:alnum:]]##=*}%%=*}
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ )
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
_store_cache SYS_ALL_PROPRTIES _sys_all_properties
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
fi
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
_values -s , "${_sys_all_properties[@]}"
|