chiark / gitweb /
random-seed: convert poolsize from bits to bytes
[elogind.git] / src / systemctl-bash-completion.sh
index 3e3380c8e0e5a3f795e9f6ae42ad1425c2464fae..6ebb792c0048fd67d0048473945096aa9de2332a 100644 (file)
 # You should have received a copy of the GNU General Public License
 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
 
+__systemctl() {
+        systemctl --no-legend "$@"
+}
+
 __contains_word () {
         local word=$1; shift
         for w in $*; do [[ $w = $word ]] && return 0; done
@@ -24,7 +28,7 @@ __contains_word () {
 __filter_units_by_property () {
         local property=$1 value=$2 ; shift ; shift
         local -a units=( $* )
-        local -a props=( $(systemctl show --property "$property" -- ${units[*]} | grep -v ^$) )
+        local -a props=( $(__systemctl show --property "$property" -- ${units[*]} | grep -v ^$) )
         for ((i=0; $i < ${#units[*]}; i++)); do
                 if [[ "${props[i]}" = "$property=$value" ]]; then
                         echo "${units[i]}"
@@ -32,20 +36,20 @@ __filter_units_by_property () {
         done
 }
 
-__get_all_units      () { systemctl list-units --full --all | awk '                 {print $1}' ; }
-__get_active_units   () { systemctl list-units --full       | awk '                 {print $1}' ; }
-__get_inactive_units () { systemctl list-units --full --all | awk '$3 == "inactive" {print $1}' ; }
-__get_failed_units   () { systemctl list-units --full       | awk '$3 == "failed"   {print $1}' ; }
+__get_all_units      () { __systemctl list-units --full --all | awk '                 {print $1}' ; }
+__get_active_units   () { __systemctl list-units --full       | awk '                 {print $1}' ; }
+__get_inactive_units () { __systemctl list-units --full --all | awk '$3 == "inactive" {print $1}' ; }
+__get_failed_units   () { __systemctl list-units --full       | awk '$3 == "failed"   {print $1}' ; }
 
 _systemctl () {
         local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
         local verb comps
 
         local -A OPTS=(
-               [STANDALONE]='--all -a --defaults --fail --force -f --full --global
-                             --help -h --no-ask-password --no-block --no-reload --no-wall
-                             --order --require --quiet -q --system --user --version'
-                      [ARG]='--kill-mode --kill-who --property -p --signal -s --type -t'
+               [STANDALONE]='--all -a --defaults --fail --ignore-dependencies --failed --force -f --full --global
+                             --help -h --no-ask-password --no-block --no-pager --no-reload --no-wall
+                             --order --require --quiet -q --privileged -P --system --user --version'
+                      [ARG]='--host -H --kill-mode --kill-who --property -p --signal -s --type -t'
         )
 
         if __contains_word "$prev" ${OPTS[ARG]}; then
@@ -60,9 +64,9 @@ _systemctl () {
                                 comps='all control main'
                         ;;
                         --kill-mode)
-                                comps='control-group process process-group'
+                                comps='control-group process'
                         ;;
-                        --property|-p)
+                        --property|-p|--host|-H)
                                 comps=''
                         ;;
                 esac
@@ -79,10 +83,11 @@ _systemctl () {
         local -A VERBS=(
                 [ALL_UNITS]='enable disable is-active is-enabled status show'
              [FAILED_UNITS]='reset-failed'
-          [STARTABLE_UNITS]='start restart reload-or-restart'
+          [STARTABLE_UNITS]='start'
           [STOPPABLE_UNITS]='stop kill try-restart condrestart'
-         [ISOLATEBLE_UNITS]='isolate'
+         [ISOLATABLE_UNITS]='isolate'
          [RELOADABLE_UNITS]='reload reload-or-try-restart force-reload'
+          [RESTARTABLE_UNITS]='restart reload-or-restart'
                      [JOBS]='cancel'
                 [SNAPSHOTS]='delete'
                      [ENVS]='set-environment unset-environment'
@@ -110,6 +115,10 @@ _systemctl () {
                 comps=$( __filter_units_by_property CanStart yes \
                       $( __get_inactive_units | grep -Ev '\.(device|snapshot)$' ))
 
+        elif __contains_word "$verb" ${VERBS[RESTARTABLE_UNITS]}; then
+                comps=$( __filter_units_by_property CanStart yes \
+                      $( __get_all_units | grep -Ev '\.(device|snapshot|socket|timer)$' ))
+
         elif __contains_word "$verb" ${VERBS[STOPPABLE_UNITS]}; then
                 comps=$( __filter_units_by_property CanStop yes \
                       $( __get_active_units ) )
@@ -129,13 +138,13 @@ _systemctl () {
                 comps=''
 
         elif __contains_word "$verb" ${VERBS[JOBS]}; then
-                comps=$( systemctl list-jobs | awk '{print $1}' )
+                comps=$( __systemctl list-jobs | awk '{print $1}' )
 
         elif __contains_word "$verb" ${VERBS[SNAPSHOTS]}; then
-                comps=$( systemctl list-units --type snapshot --full --all | awk '{print $1}' )
+                comps=$( __systemctl list-units --type snapshot --full --all | awk '{print $1}' )
 
         elif __contains_word "$verb" ${VERBS[ENVS]}; then
-                comps=$( systemctl show-environment | sed 's_\([^=]\+=\).*_\1_' )
+                comps=$( __systemctl show-environment | sed 's_\([^=]\+=\).*_\1_' )
                 compopt -o nospace
         fi