That's trickier, and I don't see a good way to do it purely within
iTerm. I'm kind of surprised that I can't find a built-in way to
open a specific profile without the mouse. Here's how I'd do it,
which may or may not be applicable to you.
Option 1: I have an iTerm hotkey window defined. I pretty much
reserve that window for quick single-shot commands, stuff that runs
and exits immediately, not something like an editor session that's
going to persist for a while. So, a local command prompt is always
just a keystroke away. I use other windows for my ssh sessions. If I
was in an ssh session and I needed to connect to a new server I'd
pop open the hotkey window and type "win whatever" to open a new
window.
Option 2: Another way is by using a hotkey manager like Butler.
(There are others that would probably do just as well, like
Quicksilver and Alfred, but Butler is the one I use.) I'd set up
either hotkeys or keywords that essentially do the same thing as the
win script. Hit the hotkey, type the server name into Butler, and
let Butler run the script.
Option 3: Automator. This would be the first option, but I couldn't
*quite* get it to work. Create a new "Service" workflow. The
workflow should be "Ask for Text" -> "Run AppleScript", the
AppleScript being the line from the win script. Set the workflow to
receive "no input" in either "any application". Save it as "Open
iTerm Profile". Then, open System Prefs. Go to Keyboard ->
Shortcuts -> App Shortcuts. Create a new shortcut for All
Applications, Menu Title "Open iTerm Profile". Assign it a
convenient keyboard shortcut. Now just hit the shortcut key.
You'll get a popup dialog asking for a profile name. Hit return and
a new iTerm window is opened. Great, so what's wrong with it? The
problem I ran into is that when the dialog pops up *it does not get
mouse focus*, so you have to mouse over and click it before you can
type. That kind of defeats the point. (See
http://blog.fosketts.net/2010/08/09/assign-keyboard-shortcut-applescript-automator-service/
for more about running Automator workflows as shortcuts.)
Option 4: Automator again. I couldn't get this one to work at all.
It worked when I ran it inside Automator, but not when I ran it as a
service. You can already open the iTerm profiles window and select a
profile with keystrokes. All you need is to have something click
"New Window" for you. I tried to record an Automator workflow of
just me clicking that button, and assigning it a shortcut as above.
Then in iTerm I hit ⌘O, typed the profile name, and pressed my
shortcut key. I expected Automator to click the button for me, but
it just gave me an unhelpful error along the lines of "An error
occurred." Maybe if it gave me a little more to go on I could figure
it out. (Edit: On closer examination of the logs it looks like this
might work if you go to Sys Prefs, Security & Privacy,
Accessibility and give iTerm permission to control your computer.)
Good luck, I hope something works out for you.
--