Skip to content

Instantly share code, notes, and snippets.

@deed02392
Last active June 14, 2019 15:02
Show Gist options
  • Save deed02392/dba0783f76c2a0b9d4627d830655399a to your computer and use it in GitHub Desktop.
Save deed02392/dba0783f76c2a0b9d4627d830655399a to your computer and use it in GitHub Desktop.
AppleScript for iTerm2 which SSHs into multiple hosts with split panes across two rows
-- Save me in ~/Library/Application Support/iTerm2/Scripts, then restart iTerm2 and find me in the Scripts menu
set hostnames to {"foo1.bar.baz", "foo2.bar.baz", "foo3.bar.baz", "foo4.bar.baz", "foo5.bar.baz", "foo6.bar.baz"}
tell application "iTerm"
activate
create window with default profile
tell current tab of current window
select
tell current session
write text "ssh " & (item 1 of hostnames)
set lower to split horizontally with default profile
set num_hosts to count of hostnames
repeat with n from 2 to num_hosts
if n - 1 is (round (num_hosts / 2)) then
select lower
write text "ssh " & (item n of hostnames)
else if n > 1 then
set new_split to split vertically with default profile
tell new_split
write text "ssh " & (item n of hostnames)
end tell
end if
end repeat
end tell
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment