Skip to content

Instantly share code, notes, and snippets.

@baybatu baybatu/README.md forked from Bonno/README.md
Created Mar 5, 2020

Embed
What would you like to do?
Opening multiple SSH sessions with iTerm automatically. To be used in an Automator flow.

Create a new Automater flow

Add 'Service'. Service receives 'no input' in 'iTerm'. Add 'Run AppleScript'.

-- Launch iTerm and log into multiple servers using SSH
tell application "iTerm"
activate
create window with default profile
-- Read serverlist from file path below
set Servers to paragraphs of (do shell script "/bin/cat $HOME/serverlist")
repeat with nextLine in Servers
-- If line in file is not empty (blank line) do the rest
if length of nextLine is greater than 0 then
-- set server to "nextLine"
-- set term to (current terminal)
-- set term to (make new terminal)
-- Open a new tab
-- tell term
tell current window
create tab with default profile
tell current session
write text "ssh " & nextLine
-- sleep to prevent errors if we spawn too fast
do shell script "/bin/sleep 0.01"
end tell
end tell
end if
end repeat
-- Close the first tab since we do not need it
-- terminate the first session of the current terminal
tell first tab of current window
close
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.