Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: compctl - aliasing hostnames

On Thu, 30 Jul 1998, Sven Guckes wrote:

> I'd like to type "ssh alias" and be connected with "ssh hostname".
> How could you "alias" a hostname with completion control?  Example:
> 	$ ssh alias
> 	guckes@hostname's password:

I just want tab completion among all of our server boxes, and I use
the following to accomplish it:

    compctl -k hostlist ssh

    function hosts(){
        unset hostlist
        echo "Enter password on hunterd for host completion.  "
        set -A hostlist `echo "select hostname,status from hosttable;"| \
          ssh dbserver "psql hostdb 2>/dev/null"|grep Active| sed 's/|/ \
          /g'|awk '{print $1}'`

        # echo "hosts are $hostlist"

"psql" is the PostgreSQL command-line query tool.  We track all of our
servers in a relational database using PostgreSQL; cf. www.postgresql.org
for more info.  We did this because I got tired of not being able to do
tab-completion on ssh's.  8^)

One could also just take the list from ~/.ssh/known-hosts, on the theory
that the weather today is pretty much like the weather yesterday.  One
could also set the completion command to run hosts(), where hosts()
either dumps the host database as it does above, or scans known-hosts,
when there's no match.

This wasn't what you asked for, but maybe some people will find it useful.

Todd Graham Lewis                                     (800) 719-4664, x2804
******Linux******         MindSpring Enterprises      tlewis@xxxxxxxxxxxxxx

Messages sorted by: Reverse Date, Date, Thread, Author