pilasguru icon

ssh multiple host iTerm2

pilasguru | PRO | 07/17/19 02:09:34 PM UTC | 0 ⭐ | 12386 👁️ | Never ⏰ | []
AppleScript |

920 B

|

None

|

0 👍

/

0 👎

set hostnames to {"18.0.0.0", "13.0.0.0", "host1", "host2.example.com"}
 
if application "iTerm2" is running then
    tell application "iTerm2"
        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 "iTerm2"
 
end if

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎