]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bash-completion: loginctl: suggest argument for --machine option
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 13 Dec 2018 17:22:40 +0000 (02:22 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 13 Dec 2018 17:22:40 +0000 (02:22 +0900)
shell-completion/bash/loginctl

index c7593ab40892d7072b558ba2cddd90d26a54343c..a0d224e9e27d9206b70d326c15186b2aef515370 100644 (file)
@@ -29,6 +29,12 @@ __get_all_sessions () { loginctl --no-legend list-sessions | { while read -r a b
 __get_all_users    () { loginctl --no-legend list-users    | { while read -r a b; do printf "%s\n" "$b"; done; } ; }
 __get_all_seats    () { loginctl --no-legend list-seats    | { while read -r a b; do printf "%s\n" "$a"; done; } ; }
 
+__get_machines() {
+        local a b
+        machinectl list --no-legend --no-pager 2>/dev/null |
+                { while read a b; do echo " $a"; done; };
+}
+
 _loginctl () {
         local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
         local i verb comps
@@ -52,6 +58,9 @@ _loginctl () {
                         --host|-H)
                                 comps=$(compgen -A hostname)
                         ;;
+                        --machine|-M)
+                                comps=$( __get_machines )
+                        ;;
                         --property|-p)
                                 comps=''
                         ;;