]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bash-completion: support ntp-servers and revert command for timedatectl
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 28 May 2019 03:48:46 +0000 (12:48 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 16 Jul 2019 21:59:12 +0000 (06:59 +0900)
shell-completion/bash/timedatectl

index 75796ff382ceb3381d0f629491b9340880c36d71..385dee7dd47566316887a47a993c5d68ec6cfdf8 100644 (file)
@@ -30,6 +30,12 @@ __get_machines() {
     machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; };
 }
 
+__get_interfaces(){
+    local name
+    for name in $(cd /sys/class/net && ls); do
+        [[ "$name" != "lo" ]] && echo "$name"
+    done
+}
 _timedatectl() {
     local i verb comps
     local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
@@ -60,6 +66,7 @@ _timedatectl() {
         [STANDALONE]='status show list-timezones timesync-status show-timesync'
         [TIMEZONES]='set-timezone'
         [TIME]='set-time'
+        [IFNAME]='ntp-servers revert'
     )
 
     for ((i=0; i < COMP_CWORD; i++)); do
@@ -77,6 +84,8 @@ _timedatectl() {
         comps=$(command timedatectl list-timezones)
     elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[TIME]}; then
         comps=''
+    elif __contains_word "$verb" ${VERBS[TIMEZONES]}; then
+        comps=$( __get_interfaces )
     fi
 
     COMPREPLY=( $(compgen -W '$comps' -- "$cur") )