chiark / gitweb /
shell-completion: show failed units as candidates for start
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 10 Apr 2013 23:31:58 +0000 (19:31 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 10 Apr 2013 23:47:21 +0000 (19:47 -0400)
Also show disabled units as candidates for reenable,
since it works and one may want to do enable-or-reenable
in one line.

TODO
shell-completion/bash/systemctl
shell-completion/systemd-zsh-completion.zsh

diff --git a/TODO b/TODO
index 369fb78546e955544ad501e6b2915530e449ebd9..0e58468aec5aa502909281d317e097596aff820b 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,6 +1,5 @@
 Bugfixes:
 Bugfixes:
-* systemctl completion doesn't want to start failed systemd-tmpfiles-setup.service
-  systemctl --system show -p Fr<TAB> default.target doesn't show anything
+* systemctl --system show -p Fr<TAB> default.target doesn't show anything
 
 * check systemd-tmpfiles for selinux context hookup for mknod(), symlink() and similar
 
 
 * check systemd-tmpfiles for selinux context hookup for mknod(), symlink() and similar
 
index b019d6aecf5683c18cd3a6722b1a9783e0083f23..aba76f65433ea5b17d92a863360a745c85eec732 100644 (file)
@@ -46,7 +46,7 @@ __get_all_units      () { __systemctl $1 list-units --all \
 __get_active_units   () { __systemctl $1 list-units       \
         | { while read -r a b; do echo " $a"; done; }; }
 __get_inactive_units () { __systemctl $1 list-units --all \
 __get_active_units   () { __systemctl $1 list-units       \
         | { while read -r a b; do echo " $a"; done; }; }
 __get_inactive_units () { __systemctl $1 list-units --all \
-        | { while read -r a b c d; do [[ $c == "inactive" ]] && echo " $a"; done; }; }
+        | { while read -r a b c d; do [[ $c == "inactive" || $c == "failed " ]] && echo " $a"; done; }; }
 __get_failed_units   () { __systemctl $1 list-units       \
         | { while read -r a b c d; do [[ $c == "failed"   ]] && echo " $a"; done; }; }
 __get_enabled_units  () { __systemctl $1 list-unit-files  \
 __get_failed_units   () { __systemctl $1 list-units       \
         | { while read -r a b c d; do [[ $c == "failed"   ]] && echo " $a"; done; }; }
 __get_enabled_units  () { __systemctl $1 list-unit-files  \
@@ -109,8 +109,9 @@ _systemctl () {
 
         local -A VERBS=(
                 [ALL_UNITS]='is-active is-failed is-enabled status show mask preset'
 
         local -A VERBS=(
                 [ALL_UNITS]='is-active is-failed is-enabled status show mask preset'
-            [ENABLED_UNITS]='disable reenable'
+            [ENABLED_UNITS]='disable'
            [DISABLED_UNITS]='enable'
            [DISABLED_UNITS]='enable'
+        [REENABLABLE_UNITS]='reenable'
              [FAILED_UNITS]='reset-failed'
           [STARTABLE_UNITS]='start'
           [STOPPABLE_UNITS]='stop condstop kill try-restart condrestart'
              [FAILED_UNITS]='reset-failed'
           [STARTABLE_UNITS]='start'
           [STOPPABLE_UNITS]='stop condstop kill try-restart condrestart'
@@ -149,6 +150,10 @@ _systemctl () {
         elif __contains_word "$verb" ${VERBS[DISABLED_UNITS]}; then
                 comps=$( __get_disabled_units $mode )
 
         elif __contains_word "$verb" ${VERBS[DISABLED_UNITS]}; then
                 comps=$( __get_disabled_units $mode )
 
+        elif __contains_word "$verb" ${VERBS[REENABLABLE_UNITS]}; then
+                comps=$( __get_disabled_units $mode;
+                         __get_enabled_units $mode )
+
         elif __contains_word "$verb" ${VERBS[STARTABLE_UNITS]}; then
                 comps=$( __filter_units_by_property $mode CanStart yes \
                       $( __get_inactive_units $mode \
         elif __contains_word "$verb" ${VERBS[STARTABLE_UNITS]}; then
                 comps=$( __filter_units_by_property $mode CanStart yes \
                       $( __get_inactive_units $mode \
index 52a5fdb4607caa90e1cea33a86083f11e4e9751a..a54e9d727ade070a2207c5ddf2f9674adef5435b 100644 (file)
@@ -455,7 +455,7 @@ _filter_units_by_property() {
 }
 
 _systemctl_active_units()  {_sys_active_units=(  $(__systemctl list-units          | { while read a b; do echo " $a"; done; }) )}
 }
 
 _systemctl_active_units()  {_sys_active_units=(  $(__systemctl list-units          | { while read a b; do echo " $a"; done; }) )}
-_systemctl_inactive_units(){_sys_inactive_units=($(__systemctl list-units --all    | { while read a b c d; do [[ $c == "inactive" ]] && echo " $a"; done; }) )}
+_systemctl_inactive_units(){_sys_inactive_units=($(__systemctl list-units --all    | { while read a b c d; do [[ $c == "inactive" || $c == "failed" ]] && echo " $a"; done; }) )}
 _systemctl_failed_units()  {_sys_failed_units=(  $(__systemctl list-units --failed | { while read a b; do echo " $a"; done; }) )}
 _systemctl_enabled_units() {_sys_enabled_units=( $(__systemctl list-unit-files     | { while read a b; do [[ $b == "enabled" ]] && echo " $a"; done; }) )}
 _systemctl_disabled_units(){_sys_disabled_units=($(__systemctl list-unit-files     | { while read a b; do [[ $b == "disabled" ]] && echo " $a"; done; }) )}
 _systemctl_failed_units()  {_sys_failed_units=(  $(__systemctl list-units --failed | { while read a b; do echo " $a"; done; }) )}
 _systemctl_enabled_units() {_sys_enabled_units=( $(__systemctl list-unit-files     | { while read a b; do [[ $b == "enabled" ]] && echo " $a"; done; }) )}
 _systemctl_disabled_units(){_sys_disabled_units=($(__systemctl list-unit-files     | { while read a b; do [[ $b == "disabled" ]] && echo " $a"; done; }) )}
@@ -475,7 +475,8 @@ for fun in disable reenable ; do
   (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
   {
     _systemctl_enabled_units
   (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
   {
     _systemctl_enabled_units
-    compadd "$@" -a - _sys_enabled_units
+    _systemctl_disabled_units
+    compadd "$@" -a - _sys_enabled_units _sys_disabled_units
   }
 done
 
   }
 done