* ssh completion snippet: host aliases from the configuration file
@ 2003-12-17 23:07 Hannu Koivisto
0 siblings, 0 replies; only message in thread
From: Hannu Koivisto @ 2003-12-17 23:07 UTC (permalink / raw)
To: Zsh Users' List
Greetings,
I modified ssh completion to dig host aliases from the
configuration file. I don't use wildcards in host patterns or give
multiple patterns, so this doesn't attempt to handle such cases. I
also have no idea whether this modification is otherwise well
written or not; I'm still a beginner in completion hacking. All
comments appreciated.
I think that a well written version (one that handles multiple
patterns and patterns with wildcards, among the other issues) of
the same subject would be nice as a standard feature. One might
also want to utilize hosts from the known_hosts file.
_ssh_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=" " key host
while read key host; do
if [[ "$key" == (#i)host ]]; then
_wanted hosts expl host \
compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" "$host"
fi
done < "$HOME/.ssh/config"
fi
}
--
Hannu
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-12-17 23:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-17 23:07 ssh completion snippet: host aliases from the configuration file Hannu Koivisto
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).