| 1 |
#compdef timedatectl |
| 2 |
# SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 |
|
| 4 |
_timedatectl_set-timezone(){ |
| 5 |
local -a _timezones |
| 6 |
_timezones=( ${(f)"$(_call_program timezones "${service}" list-timezones)"} ) |
| 7 |
compadd "$_timezones[@]" |
| 8 |
} |
| 9 |
|
| 10 |
_timedatectl_set-time(){ |
| 11 |
_message "YYYY-MM-DD HH:MM:SS" |
| 12 |
} |
| 13 |
|
| 14 |
_timedatectl_set-local-rtc(){ |
| 15 |
local -a _options |
| 16 |
_options=( |
| 17 |
'0:Maintain RTC in universal time' |
| 18 |
'1:Maintain RTC in local time' |
| 19 |
) |
| 20 |
_describe options _options |
| 21 |
} |
| 22 |
|
| 23 |
_timedatectl_set-ntp(){ |
| 24 |
local -a _options |
| 25 |
_options=( |
| 26 |
'0:Disable NTP based network time configuration' |
| 27 |
'1:Enable NTP based network time configuration' |
| 28 |
) |
| 29 |
_describe options _options |
| 30 |
} |
| 31 |
|
| 32 |
_timedatectl_command(){ |
| 33 |
local -a _timedatectl_cmds |
| 34 |
_timedatectl_cmds=( |
| 35 |
'status:Show current time settings' |
| 36 |
'set-time:Set system time' |
| 37 |
'set-timezone:Set system timezone' |
| 38 |
'list-timezones:Show known timezones' |
| 39 |
'timesync-status:Show status of systemd-timesyncd' |
| 40 |
'show-timesync:Show properties of systemd-timesyncd' |
| 41 |
'set-local-rtc:Control whether RTC is in local time' |
| 42 |
'set-ntp:Control whether NTP is enabled' |
| 43 |
) |
| 44 |
if (( CURRENT == 1 )); then |
| 45 |
_describe -t commands 'timedatectl command' _timedatectl_cmds |
| 46 |
else |
| 47 |
local curcontext="$curcontext" |
| 48 |
cmd="${${_timedatectl_cmds[(r)$words[1]:*]%%:*}}" |
| 49 |
if (( $#cmd )); then |
| 50 |
if (( $+functions[_timedatectl_$cmd] )); then |
| 51 |
_timedatectl_$cmd |
| 52 |
else |
| 53 |
_message "no more options" |
| 54 |
fi |
| 55 |
else |
| 56 |
_message "unknown timedatectl command: $words[1]" |
| 57 |
fi |
| 58 |
fi |
| 59 |
} |
| 60 |
|
| 61 |
_arguments -s \ |
| 62 |
'(- *)'{-h,--help}'[Show this help]' \ |
| 63 |
'(- *)--version[Show package version]' \ |
| 64 |
'--adjust-system-clock[Adjust system clock when changing local RTC mode]' \ |
| 65 |
'--no-pager[Do not pipe output into a pager]' \ |
| 66 |
'--no-ask-password[Do not prompt for password]' \ |
| 67 |
'(-H --host)'{-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \ |
| 68 |
'(-M --machine)'{-M+,--machine=}'[Operate on local container]:machines:_sd_machines' \ |
| 69 |
'*::timedatectl commands:_timedatectl_command' |