Hostnames as Bash Commands

Smylers Smylers at stripey.com
Fri Jan 4 18:08:39 GMT 2008


Pedro Figueiredo writes:

> ok, i'll bite:
> 
> why not

There are lots of ways of doing things like this.  I wasn't suggested
that what I came up with was the best behaviour for anybody else, nor
that it's the only (or even best) way of implementing that behaviour.

> (.bash_profile):
> 
> # 1 hostname per line
> HOSTFILE=~/.hosts

That involves manually updating a list of hosts that I might want to SSH
to; mine and Bob's configurations automatically pick that up from
previous SSH activity.

> export HOSTFILE
> complete -A hostname ssh

That offers tab completion on the ssh command; mine and Bob's
configurations let you omit the 'ssh' and just type in the hostname.

In fact my implementation relies on you already having extended Bash
completion for the ssh command (since it uses its _known_hosts
function), but getting the list of hostnames from other files that are
lying around anyway.

Smylers


More information about the london.pm mailing list