Last active
August 29, 2015 14:27
-
-
Save prabeengiri/cbdfaa2363a6988ddf00 to your computer and use it in GitHub Desktop.
Applescript to launch ITerm and ssh tunelling and ssh into multiple servers with windows splitted horizontally
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- opens 4 tab with last 3 being a single tab splitted horizontally | |
tell application "iTerm" | |
activate | |
-- create new iterm window | |
set myterm to (make new terminal) | |
tell the myterm | |
activate current session | |
--new tab | |
launch session "[ITermProfileName]" | |
tell the last session | |
write text "ssh [user]@[ip_or_domain] -L [local_port]:[remote_ip]:[remote_port] -L [local_port]:[remote_ip]:[remote_port] -L [local_port]:[remote_ip]:[remote_port]" | |
end tell | |
--new tab | |
launch session "[ITermProfileName]" | |
delay 2.0 | |
tell the last session | |
write text "ssh user@[domain_or_ip] -p[local_port] -oUserKnownHostsFile=/dev/null;" | |
delay 2.0 | |
write text "yes" | |
write text "clear" | |
end tell | |
delay 2.0 | |
-- create new tab splitted horizontally | |
tell i term application "System Events" to keystroke "d" using {command down, shift down} | |
tell the current session | |
write text "ssh user@[domain_or_ip] -p[local_port] -oUserKnownHostsFile=/dev/null;" | |
delay 2.0 | |
write text "yes" | |
write text "clear" | |
end tell | |
delay 2.0 | |
-- create new tab splitted horizontally | |
tell i term application "System Events" to keystroke "d" using {command down, shift down} | |
tell the current session | |
write text "ssh user@[domain_or_ip] -p[local_port] -oUserKnownHostsFile=/dev/null;" | |
delay 2.0 | |
write text "yes" | |
write text "clear" | |
end tell | |
-- broadcast the keyboard input across all sessions in current tab | |
tell i term application "System Events" to keystroke "i" using {command down, option down} | |
-- press ok on warning dialog box. | |
tell i term application "System Events" to keystroke return | |
end tell | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment