Sunday, June 15, 2008

Auto-complete hostnames with using bash

Having forever used tcsh, this is something new I discovered when I switched to bash.

Here's how it works:
prompt%>ssh my
becomes:
prompt%>ssh mypc.homelinux.org

Here's how to set it up:
1) Create a file similar to /etc/hosts

e.g: (/home/marke/hostfile)

---snip---
# Local PC
127.0.0.1 localhost
127.0.1.1 mypc.homelinux.org
# Other
0.0.0.0 laptop1.homelinux.org
0.0.0.0 laptop2.homelinux.org
---snip---

* note: you don't really seem to need the real IP address. Just the name. You ca even shorten it if you have resolver set correctly.

2) Add the following to your .bashrc

export HOSTFILE="/home/marke/hostfile"


Yor're done!

Enjoy!

For more info:
* man bash
* link

No comments:

Post a Comment