zsh_completion: Split out zsh _hostnamectl
This commit is contained in:
parent
799d54be0b
commit
db456cd0c6
|
@ -3363,6 +3363,9 @@ bin_PROGRAMS += \
|
||||||
dist_bashcompletion_DATA += \
|
dist_bashcompletion_DATA += \
|
||||||
shell-completion/bash/hostnamectl
|
shell-completion/bash/hostnamectl
|
||||||
|
|
||||||
|
dist_zshcompletion_DATA += \
|
||||||
|
shell-completion/zsh/_hostnamectl
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
polkitpolicy_in_files += \
|
polkitpolicy_in_files += \
|
||||||
|
|
38
shell-completion/zsh/_hostnamectl
Normal file
38
shell-completion/zsh/_hostnamectl
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
#compdef hostnamectl
|
||||||
|
|
||||||
|
_hosts_or_user_at_host() {
|
||||||
|
_alternative \
|
||||||
|
'users-hosts:: _user_at_host' \
|
||||||
|
'hosts:: _hosts'
|
||||||
|
}
|
||||||
|
|
||||||
|
_hostnamectl_command() {
|
||||||
|
local -a _hostnamectl_cmds
|
||||||
|
_hostnamectl_cmds=(
|
||||||
|
"status:Show current hostname settings"
|
||||||
|
"set-hostname:Set system hostname"
|
||||||
|
"set-icon-name:Set icon name for host"
|
||||||
|
)
|
||||||
|
if (( CURRENT == 1 )); then
|
||||||
|
_describe -t commands 'hostnamectl commands' _hostnamectl_cmds || compadd "$@"
|
||||||
|
else
|
||||||
|
local curcontext="$curcontext"
|
||||||
|
cmd="${${_hostnamectl_cmds[(r)$words[1]:*]%%:*}}"
|
||||||
|
if (( $#cmd )); then
|
||||||
|
[[ $cmd == status ]] && msg="no options" || msg="options for $cmd"
|
||||||
|
_message "$msg"
|
||||||
|
else
|
||||||
|
_message "unknown hostnamectl command: $words[1]"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_arguments -s \
|
||||||
|
{-h,--help}'[Show this help]' \
|
||||||
|
'--version[Show package version]' \
|
||||||
|
'--transient[Only set transient hostname]' \
|
||||||
|
'--static[Only set static hostname]' \
|
||||||
|
'--pretty[Only set pretty hostname]' \
|
||||||
|
'--no-ask-password[Do not prompt for password]' \
|
||||||
|
{-H,--host=}'[Operate on remote host]:userathost:_hosts_or_user_at_host' \
|
||||||
|
'*::hostnamectl commands:_hostnamectl_command'
|
|
@ -1,20 +1,9 @@
|
||||||
#compdef journalctl hostnamectl localectl timedatectl systemd-coredumpctl udevadm systemd-analyze systemd-cat systemd-ask-password systemd-cgls systemd-cgtop systemd-delta systemd-detect-virt systemd-inhibit systemd-machine-id-setup systemd-notify systemd-nspawn systemd-tmpfiles systemd-tty-ask-password-agent machinectl
|
#compdef journalctl localectl timedatectl systemd-coredumpctl udevadm systemd-analyze systemd-cat systemd-ask-password systemd-cgls systemd-cgtop systemd-delta systemd-detect-virt systemd-inhibit systemd-machine-id-setup systemd-notify systemd-nspawn systemd-tmpfiles systemd-tty-ask-password-agent machinectl
|
||||||
|
|
||||||
_ctls()
|
_ctls()
|
||||||
{
|
{
|
||||||
local curcontext="$curcontext" state lstate line
|
local curcontext="$curcontext" state lstate line
|
||||||
case "$service" in
|
case "$service" in
|
||||||
hostnamectl)
|
|
||||||
_arguments -s \
|
|
||||||
{-h,--help}'[Show this help]' \
|
|
||||||
'--version[Show package version]' \
|
|
||||||
'--transient[Only set transient hostname]' \
|
|
||||||
'--static[Only set static hostname]' \
|
|
||||||
'--pretty[Only set pretty hostname]' \
|
|
||||||
'--no-ask-password[Do not prompt for password]' \
|
|
||||||
{-H,--host=}'[Operate on remote host]:userathost:_hosts_or_user_at_host' \
|
|
||||||
'*::hostnamectl commands:_hostnamectl_command'
|
|
||||||
;;
|
|
||||||
journalctl)
|
journalctl)
|
||||||
_arguments -s \
|
_arguments -s \
|
||||||
'--since=[Start showing entries newer or of the specified date]:YYYY-MM-DD HH\:MM\:SS' \
|
'--since=[Start showing entries newer or of the specified date]:YYYY-MM-DD HH\:MM\:SS' \
|
||||||
|
@ -323,27 +312,6 @@ _journal_fields() {
|
||||||
_describe 'possible values' _fields
|
_describe 'possible values' _fields
|
||||||
}
|
}
|
||||||
|
|
||||||
_hostnamectl_command() {
|
|
||||||
local -a _hostnamectl_cmds
|
|
||||||
_hostnamectl_cmds=(
|
|
||||||
"status:Show current hostname settings"
|
|
||||||
"set-hostname:Set system hostname"
|
|
||||||
"set-icon-name:Set icon name for host"
|
|
||||||
)
|
|
||||||
if (( CURRENT == 1 )); then
|
|
||||||
_describe -t commands 'hostnamectl commands' _hostnamectl_cmds || compadd "$@"
|
|
||||||
else
|
|
||||||
local curcontext="$curcontext"
|
|
||||||
cmd="${${_hostnamectl_cmds[(r)$words[1]:*]%%:*}}"
|
|
||||||
if (( $#cmd )); then
|
|
||||||
[[ $cmd == status ]] && msg="no options" || msg="options for $cmd"
|
|
||||||
_message "$msg"
|
|
||||||
else
|
|
||||||
_message "unknown hostnamectl command: $words[1]"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
_localectl_set-locale() {
|
_localectl_set-locale() {
|
||||||
local -a _confs _locales
|
local -a _confs _locales
|
||||||
local expl suf
|
local expl suf
|
||||||
|
|
Loading…
Reference in a new issue