Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
An improved "hosts" completion handling
- X-seq: zsh-users 10959
- From: "Christopher Browne" <cbbrowne@xxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: An improved "hosts" completion handling
- Date: Wed, 8 Nov 2006 17:23:29 +0000
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=AaXdJnKt5i1YrRdIWZpTGQg/F8vPUqGbaaoDqU9UDLYjj84K3/5c5FUStZVCw+ltuJw1ap8iDVqU4ll8YWAEkFK1zsLclWZskdWEtn0SfNk2q2Qso0vwfTS4UqlhJ/QbTDlTe8E8Gccs6A19iX0QefJe15fkJzRd0ywDcrAbkgg=
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
I had been using some code I'd seen "out there" to pull known_hosts as
a way of setting up a $hosts value so that ssh/telnet could do tab
completion on host names.
I think this was the source, more or less...
http://www.2701.org/archive/200405030000.html
With the changes in openssh, of late, ~/.ssh/known_hosts is now
littered with encoded host names that were getting pulled in such that
I'd get tab completion looking like the following:
cbbrowne@dba2:~/Slony-I/slony1-HEAD-pristine> ssh rg ssh
rg570-da-logdbs
Wednesday 17:20:40
rg570-da-logdbs
rg570-da-logdbs1
rg570-da-logdbs1.nj.site\ ssh-rsa\
AAAAB3NzaC1yc2EAAAABIwAAAIEAn7BPZtUqqjJzpVszaI71KUCVyvGicrOvUTFO4EiGzCHm7lYtJIbN0MblFo4CGwq3Z7cgzMwn/qdSxIXFnlIHIpPHojcZAnbSFXrJMIKB45VjK6XgFOB7ZQtpKg252F/nXV7vaTa/xgI6H+tza4w5UI5AZnrD/knq+l3qtSyuBDU=
rg570-da-logdbs2
rg570-da-logdbs2.nj.site\ ssh-rsa\
AAAAB3NzaC1yc2EAAAABIwAAAIEAn7BPZtUqqjJzpVszaI71KUCVyvGicrOvUTFO4EiGzCHm7lYtJIbN0MblFo4CGwq3Z7cgzMwn/qdSxIXFnlIHIpPHojcZAnbSFXrJMIKB45VjK6XgFOB7ZQtpKg252F/nXV7vaTa/xgI6H+tza4w5UI5AZnrD/knq+l3qtSyuBDU=
Bleah. That's awful.
The following showed an alternative that does some better parsing, as
well as reading IP addresses.
http://www.zsh.org/mla/workers/2006/msg00280.html
Here's my adaption of this:
for file in $HOME/.ssh/known_hosts /etc/ssh/known_hosts; do
if [[ -r ${file} ]] ; then
_cache_hosts+=(${${${(u)${(f)"$(<${file})"}%%[
,|#]*}:#(#s)[0-9]##.[0-9]##.[0-9]##.[0-9]##(#e)}:#(#s)[0-9a-f:]##(#e)})
fi
done
zstyle ':completion:*:hosts' hosts $_cache_hosts
Hope that is of assistance to others...
--
http://linuxfinances.info/info/linuxdistributions.html
"... memory leaks are quite acceptable in many applications ..."
(Bjarne Stroustrup, The Design and Evolution of C++, page 220)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author