From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2902 invoked from network); 17 Dec 2003 23:07:28 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 17 Dec 2003 23:07:28 -0000 Received: (qmail 9464 invoked by alias); 17 Dec 2003 23:07:08 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6915 Received: (qmail 9448 invoked from network); 17 Dec 2003 23:07:06 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 17 Dec 2003 23:07:06 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [195.197.252.71] by sunsite.dk (MessageWall 1.0.8) with SMTP; 17 Dec 2003 23:7:6 -0000 Received: from azure by lynx.tre-1.ionific.com with local (Exim 3.35 #1 (Debian)) id 1AWkl0-0001ed-00; Thu, 18 Dec 2003 01:07:06 +0200 To: Zsh Users' List Subject: ssh completion snippet: host aliases from the configuration file Mail-copies-to: nobody From: Hannu Koivisto Date: Thu, 18 Dec 2003 01:07:06 +0200 Message-ID: <87wu8vavs5.fsf@lynx.tre-1.ionific.com> User-Agent: Gnus/5.090014 (Oort Gnus v0.14) Emacs/21.2 (i386-debian-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: Hannu Koivisto 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