mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-25 05:31:19 +02:00
users/9688: improved _ssh_hosts from Hanna Koivisto
This commit is contained in:
parent
fe3b0d5849
commit
b1c72569b9
2 changed files with 23 additions and 3 deletions
|
@ -1,3 +1,9 @@
|
|||
2005-11-18 Peter Stephenson <pws@csr.com>
|
||||
|
||||
* users/9688: Completion/Unix/Command/_ssh: improved
|
||||
_ssh_hosts from Hannu Koivisto <azure@iki.fi>; also
|
||||
rationalise reference to hosts to "remote host name".
|
||||
|
||||
2005-11-17 Clint Adams <clint@zsh.org>
|
||||
|
||||
* 22005: Completion/Unix/Command/_flasher: completion
|
||||
|
|
|
@ -283,11 +283,11 @@ _ssh () {
|
|||
elif compset -P '*@'; then
|
||||
suf=( -S '' )
|
||||
compset -S ':*' || suf=( -S : )
|
||||
_wanted hosts expl host _ssh_hosts $suf && ret=0
|
||||
_wanted hosts expl 'remote host name' _ssh_hosts $suf && ret=0
|
||||
else
|
||||
_alternative \
|
||||
'files:: _files' \
|
||||
'hosts:host:_ssh_hosts -S:' \
|
||||
'hosts:remote host name:_ssh_hosts -S:' \
|
||||
'users:user:_ssh_users -qS@' && ret=0
|
||||
fi
|
||||
;;
|
||||
|
@ -298,7 +298,7 @@ _ssh () {
|
|||
_wanted hosts expl host _ssh_hosts -S: && ret=0
|
||||
else
|
||||
_alternative \
|
||||
'hosts:host:_ssh_hosts -S:' \
|
||||
'hosts:remote host name:_ssh_hosts -S:' \
|
||||
'users:user:_ssh_users -qS@' && ret=0
|
||||
fi
|
||||
;;
|
||||
|
@ -311,12 +311,26 @@ _ssh_users () {
|
|||
}
|
||||
|
||||
_ssh_hosts () {
|
||||
local -a config_hosts
|
||||
|
||||
if [[ "$IPREFIX" == *@ ]]; then
|
||||
_combination -s '[:@]' my-accounts users-hosts "users=${IPREFIX/@}" hosts "$@"
|
||||
else
|
||||
_combination -s '[:@]' my-accounts users-hosts \
|
||||
${opt_args[-l]:+"users=${opt_args[-l]:q}"} hosts "$@"
|
||||
fi
|
||||
if [[ -r "$HOME/.ssh/config" ]]; then
|
||||
local IFS=$'\t ' key host
|
||||
while read key host; do
|
||||
if [[ "$key" == (#i)host ]]; then
|
||||
config_hosts+=("$host")
|
||||
fi
|
||||
done < "$HOME/.ssh/config"
|
||||
if (( ${#config_hosts} )); then
|
||||
_wanted hosts expl 'remote host name' \
|
||||
compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" $config_hosts
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
_ssh "$@"
|
||||
|
|
Loading…
Reference in a new issue