]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shell-completion: update systemctl bash completion 1150/head
authorEvgeny Vereshchagin <evvers@ya.ru>
Fri, 4 Sep 2015 20:04:10 +0000 (23:04 +0300)
committerEvgeny Vereshchagin <evvers@ya.ru>
Fri, 4 Sep 2015 20:04:10 +0000 (23:04 +0300)
Many new options have been added since the bash completion was last
updated.

shell-completion/bash/systemctl.in

index 21c79cae8e69bfc99996549bda9ca2630a66b90d..4d63e2870f177acc92a0ba9bf8f1f835318c157d 100644 (file)
@@ -85,6 +85,12 @@ __get_masked_units   () { __systemctl $1 list-unit-files  \
         | { while read -r a b c  ; do [[ $b == "masked"   ]] && echo " $a"; done; }; }
 __get_all_unit_files () { { __systemctl $1 list-unit-files; } | { while read -r a b; do echo " $a"; done; }; }
 
+__get_machines() {
+        local a b
+        (machinectl list-images --no-legend --no-pager; machinectl list --no-legend --no-pager) | \
+               { while read a b; do echo " $a"; done; } | sort -u;
+}
+
 _systemctl () {
         local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
         local i verb comps mode
@@ -92,8 +98,10 @@ _systemctl () {
         local -A OPTS=(
                [STANDALONE]='--all -a --reverse --after --before --defaults --failed --force -f --full -l --global
                              --help -h --no-ask-password --no-block --no-legend --no-pager --no-reload --no-wall
-                             --quiet -q --privileged -P --system --user --version --runtime --recursive -r --firmware-setup'
-                      [ARG]='--host -H --kill-who --property -p --signal -s --type -t --state --job-mode --root'
+                             --quiet -q --privileged -P --system --user --version --runtime --recursive -r --firmware-setup
+                             --show-types -i --ignore-inhibitors --plain'
+                      [ARG]='--host -H --kill-who --property -p --signal -s --type -t --state --job-mode --root
+                             --preset-mode -n --lines -o --output -M --machine'
         )
 
         if __contains_word "--user" ${COMP_WORDS[*]}; then
@@ -132,6 +140,16 @@ _systemctl () {
                         --property|-p)
                                 comps=$(__systemd_properties $mode)
                         ;;
+                        --preset-mode)
+                                comps='full enable-only disable-only'
+                        ;;
+                        --output|-o)
+                                comps='short short-iso short-precise short-monotonic verbose export json
+                                       json-pretty json-sse cat'
+                        ;;
+                        --machine|-M)
+                                comps=$( __get_machines )
+                        ;;
                 esac
                 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
                 return 0