Skip to content

Instantly share code, notes, and snippets.

@amosshapira
Forked from mandys/ssh_multiple.scpt
Created July 10, 2018 01:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amosshapira/9cf0e082cd26420ce326f8aa75522160 to your computer and use it in GitHub Desktop.
Save amosshapira/9cf0e082cd26420ce326f8aa75522160 to your computer and use it in GitHub Desktop.
set hostnames to {"web01", "sys01", "mem01", "redis01"}
if application "iTerm" is running then
tell application "iTerm"
create window with default profile
tell current tab of current window
select
tell current session
-- make the window fullscreen
tell application "System Events" to key code 36 using command down
split horizontally with default profile
set num_hosts to count of hostnames
repeat with n from 1 to num_hosts
if n - 1 is (round (num_hosts / 2)) then
-- move to lower split
tell application "System Events" to keystroke "]" using command down
else if n > 1 then
-- split vertically
tell application "System Events" to keystroke "d" using command down
end if
delay 1
write text "ssh " & (item n of hostnames)
end repeat
end tell
end tell
end tell
else
activate application "iTerm"
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment