summaryrefslogtreecommitdiff
path: root/shell-completion
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-01-10 23:03:26 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-01-10 23:21:26 +0900
commit68c7139a4b78f5e3fb61d0c5b642a9260a89dd7a (patch)
tree8fdc8358285a18071cd5cfa79d04e1926341bfac /shell-completion
parente352389a023933b61e1db5171040ca3876164061 (diff)
downloadsystemd-68c7139a4b78f5e3fb61d0c5b642a9260a89dd7a.tar.gz
bash-completion: timedatectl: suggests hostname and machine name
Diffstat (limited to 'shell-completion')
-rw-r--r--shell-completion/bash/timedatectl14
1 files changed, 11 insertions, 3 deletions
diff --git a/shell-completion/bash/timedatectl b/shell-completion/bash/timedatectl
index b9d00811e3..13b99f22ba 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'
)