From: Yu Watanabe Date: Wed, 10 Jan 2018 14:03:26 +0000 (+0900) Subject: bash-completion: timedatectl: suggests hostname and machine name X-Git-Tag: v237~106^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=68c7139a4b78f5e3fb61d0c5b642a9260a89dd7a;p=platform%2Fupstream%2Fsystemd.git bash-completion: timedatectl: suggests hostname and machine name --- diff --git a/shell-completion/bash/timedatectl b/shell-completion/bash/timedatectl index b9d0081..13b99f2 100644 --- a/shell-completion/bash/timedatectl +++ b/shell-completion/bash/timedatectl @@ -25,16 +25,24 @@ __contains_word () { done } +__get_machines() { + local a b + machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; }; +} + _timedatectl() { local i verb comps local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local OPTS='-h --help --version --adjust-system-clock --no-pager - --no-ask-password -H --host --machine' + --no-ask-password -H --host -M --machine' if __contains_word "$prev" $OPTS; then case $prev in --host|-H) - comps='' + comps=$(compgen -A hostname) + ;; + --machine|-M) + comps=$( __get_machines ) ;; esac COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) @@ -48,7 +56,7 @@ _timedatectl() { local -A VERBS=( [BOOLEAN]='set-local-rtc set-ntp' - [STANDALONE]='status set-time list-timezones' + [STANDALONE]='status list-timezones' [TIMEZONES]='set-timezone' [TIME]='set-time' )