SHARE
TWEET

ssh multiple host iTerm2

pilasguru Jul 17th, 2019 115 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. set hostnames to {"18.0.0.0", "13.0.0.0", "host1", "host2.example.com"}
  2.  
  3. if application "iTerm2" is running then
  4.     tell application "iTerm2"
  5.         create window with default profile
  6.         tell current tab of current window
  7.             select
  8.             tell current session
  9.  
  10.                 -- make the window fullscreen
  11.                 tell application "System Events" to key code 36 using command down
  12.                 split horizontally with default profile
  13.  
  14.                 set num_hosts to count of hostnames
  15.                 repeat with n from 1 to num_hosts
  16.                     if n - 1 is (round (num_hosts / 2)) then
  17.                         -- move to lower split
  18.                         tell application "System Events" to keystroke "]" using command down
  19.                     else if n > 1 then
  20.                         -- split vertically
  21.                         tell application "System Events" to keystroke "d" using command down
  22.                     end if
  23.                     delay 1
  24.                     write text "ssh " & (item n of hostnames)
  25.                 end repeat
  26.             end tell
  27.         end tell
  28.     end tell
  29. else
  30.     activate application "iTerm2"
  31.  
  32. end if
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top