bash-completion: support ntp-servers and revert command for timedatectl
This commit is contained in:
parent
159a855b34
commit
0a0564a1b5
|
@ -30,6 +30,12 @@ __get_machines() {
|
||||||
machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; };
|
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() {
|
_timedatectl() {
|
||||||
local i verb comps
|
local i verb comps
|
||||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
|
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'
|
[STANDALONE]='status show list-timezones timesync-status show-timesync'
|
||||||
[TIMEZONES]='set-timezone'
|
[TIMEZONES]='set-timezone'
|
||||||
[TIME]='set-time'
|
[TIME]='set-time'
|
||||||
|
[IFNAME]='ntp-servers revert'
|
||||||
)
|
)
|
||||||
|
|
||||||
for ((i=0; i < COMP_CWORD; i++)); do
|
for ((i=0; i < COMP_CWORD; i++)); do
|
||||||
|
@ -77,6 +84,8 @@ _timedatectl() {
|
||||||
comps=$(command timedatectl list-timezones)
|
comps=$(command timedatectl list-timezones)
|
||||||
elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[TIME]}; then
|
elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[TIME]}; then
|
||||||
comps=''
|
comps=''
|
||||||
|
elif __contains_word "$verb" ${VERBS[TIMEZONES]}; then
|
||||||
|
comps=$( __get_interfaces )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
|
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
|
||||||
|
|
Loading…
Reference in New Issue