Created
September 20, 2014 13:21
-
-
Save seyhunak/04c8d84a25676d53b3a4 to your computer and use it in GitHub Desktop.
AppleScript - Iterm2 Multiple SSH Sessions and Panes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set hostnames to {"host1", "host2", "host3"} | |
activate application "iTerm" | |
tell application "iTerm" | |
activate | |
-- ssh in split panes to my queue processor hosts | |
set myterm to (make new terminal) | |
tell myterm | |
launch session "Default Session" | |
-- make the window fullscreen | |
tell i term application "System Events" to key code 36 using command down | |
-- split horizontally | |
tell i term application "System Events" to keystroke "D" using command down | |
-- move to upper split | |
tell i term application "System Events" to keystroke "[" using command down | |
set num_hosts to count of hostnames | |
repeat with n from 1 to num_hosts | |
if n - 1 is num_hosts / 2 then | |
-- move to lower split | |
tell i term application "System Events" to keystroke "]" using command down | |
else if n > 1 then | |
-- split vertically | |
tell i term application "System Events" to keystroke "d" using command down | |
end if | |
delay 1 | |
tell the current session to write text "ssh " & (item n of hostnames) | |
end repeat | |
end tell | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi there.
I've tried your script (and changed the hosts at the top, and it currently contains one IP address) and I get this error:

Any way you know how to fix this?
Thanks for your script nonetheless :)