X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=shell-completion%2Fzsh%2F_systemctl.in;fp=shell-completion%2Fzsh%2F_systemctl.in;h=1435dee7243315462fb598dd4fb681f6cc8860f2;hb=e9a19bd882ff8a2c8aef5c63b39525ea231e5fb9;hp=ca4b899bb3911998afd9d27bb8759013c6189d4c;hpb=f29c77bc0179b0fa57407dbe30b495be9f5ad2e8;p=elogind.git diff --git a/shell-completion/zsh/_systemctl.in b/shell-completion/zsh/_systemctl.in index ca4b899bb..1435dee72 100644 --- a/shell-completion/zsh/_systemctl.in +++ b/shell-completion/zsh/_systemctl.in @@ -139,6 +139,8 @@ _filter_units_by_property() { } _systemctl_all_units() { { __systemctl list-unit-files; __systemctl list-units --all; } | { while read -r a b; do echo -E - " $a"; done; } } +_systemctl_get_template_names() { __systemctl list-unit-files | { while read -r a b; do [[ $a =~ @\. ]] && echo -E - " ${a%%@.*}@"; done; } } + _systemctl_active_units() {_sys_active_units=( $(__systemctl list-units | { while read -r a b; do echo -E - " $a"; done; }) )} _systemctl_startable_units(){_sys_startable_units=($(__systemctl list-units --state inactive,failed -- $(_systemctl_all_units) | { while read -r a b c d; do [[ $b == "loaded" ]] && echo -E - " $a"; done; }) )} @@ -158,20 +160,24 @@ for fun in is-active is-failed is-enabled status show cat mask preset help list- done # Completion functions for ENABLED_UNITS -for fun in disable reenable ; do - (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() - { +(( $+functions[_systemctl_disable] )) || _systemctl_disable() +{ + _systemctl_enabled_units + compadd "$@" -a - _sys_enabled_units +} + +(( $+functions[_systemctl_reenable] )) || _systemctl_reenable() +{ _systemctl_enabled_units _systemctl_disabled_units - compadd "$@" -a - _sys_enabled_units _sys_disabled_units - } -done + compadd "$@" -a - _sys_enabled_units _sys_disabled_units $(_systemctl_get_template_names) +} # Completion functions for DISABLED_UNITS (( $+functions[_systemctl_enable] )) || _systemctl_enable() { _systemctl_disabled_units - compadd "$@" -a - _sys_disabled_units + compadd "$@" -a - _sys_disabled_units $(_systemctl_get_template_names) } # Completion functions for FAILED_UNITS