Query ssh config and build a dynamic menu using ratmen
======================================================
The file `~/.ssh/config' contains the configuration for how to connect
for a number of hosts.
For each host, it contains a block with a number of lines.
The general format of these blocks is:
Host foo
Hostname bar.example.com
Port 123
User baz
IdentityFile ~/.ssh/id_rsa
`foo' is an alias for the host, you can choose anything here, as long
as it is an unique name.
Script to create a menu
-----------------------
Below follows a script that show the alias names in a menu, using
ratmen, to start a ssh session to the selected host.
The script takes the alias names from the `Host' lines (the first line
of each of these blocks) and dynamically creates a command that opens
a menu using ratmen.
Perhaps there is a block for `Host *' in your ~/.ssh/config,
f.e., with a keep-alive statement, or a default user.
This is the reason for the `if'-statement in the awk command.
Ratpoisonrc
-----------
To call it from ratpoison, I added the following line to
`~/.ratpoisonrc':
bind g exec ~/bin/ratssh.sh
Here, it uses a binding to key 'g' (mnemonic: "go").
Select a key binding that is not yet used,
My ratpoison prefix is the default Ctrl-t.
When I hit `Ctrl-t g', ratpoison calls the script, which creates the
menu on the fly. I select a host, and a new urxvt window is started
with ssh to the specific host.
ratmen or ratmenu
-----------------
There are two menu applications for ratpoison. `ratmen' and `ratmenu'.
They work more or less the same. If you can't find ratmen, try
to use ratmenu.
For `ratmenu', the script perhaps needs some tweaking.