zsh-completion: systemctl: pass only $PREFIX* to list-unit*
Using a leading * and $SUFFIX produces misleading results. Let's imagine that one mistypes nect instead of netc, they will get a rather misleading completion like: sys-fs-fuse-connections.mount Not to mention that the execution time is up by ~1/3. time systemctl list-unit-files netctl* -> ~12ms time systemctl list-unit-files *netctl* -> ~17ms Furthermore more units are matched, leading to greater execution time of `systemctl show' in _filter_units_by_property Use only $PREFIX*, removing the leading * and trailing $SUFFIX*. Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
This commit is contained in:
parent
c839b729c5
commit
ff728637cc
|
@ -135,29 +135,29 @@ _filter_units_by_property() {
|
|||
echo -E - "${(@g:o:)${(k@)props[(Re)$property=$value]}#Id=}"
|
||||
}
|
||||
|
||||
_systemctl_get_template_names() { echo -E - ${^${(M)${(f)"$(__systemctl list-unit-files "*$PREFIX*$SUFFIX*" )"}##*@.[^[:space:]]##}%%@.*}\@ }
|
||||
_systemctl_get_template_names() { echo -E - ${^${(M)${(f)"$(__systemctl list-unit-files "$PREFIX*" )"}##*@.[^[:space:]]##}%%@.*}\@ }
|
||||
|
||||
|
||||
_systemctl_active_units() {_sys_active_units=( ${${(f)"$(__systemctl list-units "*$PREFIX*$SUFFIX*" )"}%% *} )}
|
||||
_systemctl_active_units() {_sys_active_units=( ${${(f)"$(__systemctl list-units "$PREFIX*" )"}%% *} )}
|
||||
|
||||
_systemctl_startable_units(){
|
||||
_sys_startable_units=( $( _filter_units_by_property ActiveState inactive $(
|
||||
_filter_units_by_property CanStart yes ${${${(f)"$(
|
||||
__systemctl $mode list-unit-files --state enabled,disabled,static "*$PREFIX*$SUFFIX*"
|
||||
__systemctl $mode list-units --state inactive,failed "*$PREFIX*$SUFFIX*"
|
||||
__systemctl $mode list-unit-files --state enabled,disabled,static "$PREFIX*"
|
||||
__systemctl $mode list-units --state inactive,failed "$PREFIX*"
|
||||
)"}:#*@.*}%%[[:space:]]*}
|
||||
)) )
|
||||
}
|
||||
|
||||
_systemctl_restartable_units(){
|
||||
_sys_restartable_units=( $( _filter_units_by_property CanStart yes ${${${(f)"$(
|
||||
__systemctl $mode list-unit-files --state enabled,disabled,static "*$PREFIX*$SUFFIX*"
|
||||
__systemctl $mode list-units "*$PREFIX*$SUFFIX*"
|
||||
__systemctl $mode list-unit-files --state enabled,disabled,static "$PREFIX*"
|
||||
__systemctl $mode list-units "$PREFIX*"
|
||||
)"}:#*@.*}%%[[:space:]]*} ) )
|
||||
}
|
||||
|
||||
_systemctl_failed_units() {_sys_failed_units=( ${${(f)"$(__systemctl list-units --state=failed "*$PREFIX*$SUFFIX*" )"}%% *} ) }
|
||||
_systemctl_unit_state() { typeset -gA _sys_unit_state; _sys_unit_state=( $(__systemctl list-unit-files "*$PREFIX*$SUFFIX*" ) ) }
|
||||
_systemctl_failed_units() {_sys_failed_units=( ${${(f)"$(__systemctl list-units --state=failed "$PREFIX*" )"}%% *} ) }
|
||||
_systemctl_unit_state() { typeset -gA _sys_unit_state; _sys_unit_state=( $(__systemctl list-unit-files "$PREFIX*" ) ) }
|
||||
|
||||
local fun
|
||||
# Completion functions for ALL_UNITS
|
||||
|
|
Loading…
Reference in a new issue