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 |