From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7456 invoked from network); 8 Nov 2006 17:23:53 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO,INFO_TLD autolearn=no version=3.1.7 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 8 Nov 2006 17:23:53 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 77415 invoked from network); 8 Nov 2006 17:23:44 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 8 Nov 2006 17:23:44 -0000 Received: (qmail 5011 invoked by alias); 8 Nov 2006 17:23:35 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10959 Received: (qmail 5001 invoked from network); 8 Nov 2006 17:23:35 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 8 Nov 2006 17:23:35 -0000 Received: (qmail 76357 invoked from network); 8 Nov 2006 17:23:35 -0000 Received: from nz-out-0102.google.com (64.233.162.204) by a.mx.sunsite.dk with SMTP; 8 Nov 2006 17:23:32 -0000 Received: by nz-out-0102.google.com with SMTP id 13so1372509nzp for ; Wed, 08 Nov 2006 09:23:30 -0800 (PST) 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= Received: by 10.65.236.14 with SMTP id n14mr10240514qbr.1163006609360; Wed, 08 Nov 2006 09:23:29 -0800 (PST) Received: by 10.65.254.2 with HTTP; Wed, 8 Nov 2006 09:23:29 -0800 (PST) Message-ID: Date: Wed, 8 Nov 2006 17:23:29 +0000 From: "Christopher Browne" To: zsh-users@sunsite.dk Subject: An improved "hosts" completion handling MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline 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)