diff options
author | William Giokas <1007380@gmail.com> | 2013-07-29 14:05:48 -0500 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-08-02 10:43:31 -0400 |
commit | db456cd0c65d0e7375b09b72ae6fb60f09e2eb6e (patch) | |
tree | 8036d7454400e3e50fd6286d11cdbd758085408b /shell-completion/zsh/_hostnamectl | |
parent | 799d54be0b681c0329539fca604261994e7f8c0e (diff) |
zsh_completion: Split out zsh _hostnamectl
Diffstat (limited to 'shell-completion/zsh/_hostnamectl')
-rw-r--r-- | shell-completion/zsh/_hostnamectl | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/shell-completion/zsh/_hostnamectl b/shell-completion/zsh/_hostnamectl new file mode 100644 index 0000000000..bc4441d560 --- /dev/null +++ b/shell-completion/zsh/_hostnamectl @@ -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' |