daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
84b277
From 233b0373a3d75e277ad5a232a65567395da57f0e Mon Sep 17 00:00:00 2001
84b277
From: Lukas Nykryn <lnykryn@redhat.com>
84b277
Date: Tue, 23 Sep 2014 14:59:11 +0200
84b277
Subject: [PATCH] bash-completion: add verb set-property
84b277
84b277
Resolves: #1064487
84b277
---
84b277
 shell-completion/bash/systemctl | 12 +++++++++++-
84b277
 1 file changed, 11 insertions(+), 1 deletion(-)
84b277
84b277
diff --git a/shell-completion/bash/systemctl b/shell-completion/bash/systemctl
84b277
index 84149e3..efe8485 100644
84b277
--- a/shell-completion/bash/systemctl
84b277
+++ b/shell-completion/bash/systemctl
84b277
@@ -25,7 +25,7 @@ __systemctl() {
84b277
 __systemd_properties() {
84b277
         local mode=$1
84b277
         { __systemctl -a $mode show;
84b277
-         systemd --dump-configuration-items; } |
84b277
+         /usr/lib/systemd/systemd --dump-configuration-items; } |
84b277
         while IFS='=' read -r key value; do
84b277
             [[ $value ]] && echo "$key"
84b277
         done
84b277
@@ -77,6 +77,8 @@ _systemctl () {
84b277
                       [ARG]='--host -H --kill-mode --kill-who --property -p --signal -s --type -t --state --root'
84b277
         )
84b277
 
84b277
+        local -A PROPS='CPUAccounting= MemoryAccounting= BlockIOAccounting= MemoryLimit= CPUShares= BlockIOWeight= DevicePolicy= DeviceAllow= BlockIOReadBandwidth= BlockIOWriteBandwidth= BlockIODeviceWeight='
84b277
+
84b277
         if __contains_word "--user" ${COMP_WORDS[*]}; then
84b277
             mode=--user
84b277
         else
84b277
@@ -136,6 +138,7 @@ _systemctl () {
84b277
              [MASKED_UNITS]='unmask'
84b277
                      [JOBS]='cancel'
84b277
                 [SNAPSHOTS]='delete'
84b277
+               [PROPERTIES]='set-property'
84b277
                      [ENVS]='set-environment unset-environment'
84b277
                [STANDALONE]='daemon-reexec daemon-reload default
84b277
                              emergency exit halt hibernate hybrid-sleep kexec list-jobs
84b277
@@ -220,6 +223,13 @@ _systemctl () {
84b277
         elif __contains_word "$verb" ${VERBS[TARGETS]}; then
84b277
                 comps=$( __systemctl $mode list-unit-files --type target --full --all \
84b277
                         | { while read -r a b; do echo " $a"; done; } )
84b277
+        elif __contains_word "$verb" ${VERBS[PROPERTIES]}; then
84b277
+                if __contains_word "$prev" ${VERBS[PROPERTIES]}; then
84b277
+                        comps=$( __get_active_units $mode )
84b277
+                else
84b277
+                        comps=$PROPS
84b277
+                        compopt -o nospace
84b277
+                fi
84b277
         fi
84b277
 
84b277
         COMPREPLY=( $(compgen -W '$comps' -- "$cur") )