Created
July 3, 2012 23:56
-
-
Save jonleung/3044229 to your computer and use it in GitHub Desktop.
Resuming SSH + Screen sessions in iTerm
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
#Don't forget to do a 'chmod +x iterm.sh' | |
#Also, obviously I don't really know how to use AppleScript so this is really really crappy AppleScript code lol... | |
osascript <<ENDSCRIPT | |
tell application "iTerm" | |
activate | |
--terminate the first session of the first terminal | |
set myterm to (make new terminal) | |
tell myterm | |
launch session "Panes" | |
tell i term application "System Events" to keystroke "D" using command down | |
tell i term application "System Events" to keystroke "D" using command down | |
tell i term application "System Events" to key code 30 using command down | |
tell i term application "System Events" to keystroke "d" using command down | |
tell i term application "System Events" to key code 30 using command down | |
tell i term application "System Events" to keystroke "d" using command down | |
tell i term application "System Events" to key code 30 using command down | |
tell i term application "System Events" to key code 30 using command down | |
tell i term application "System Events" to keystroke "d" using command down | |
tell i term application "System Events" to key code 30 using command down | |
tell i term application "System Events" to key code 30 using command down | |
tell i term application "System Events" to keystroke "d" using command down | |
tell i term application "System Events" to key code 30 using command down | |
tell i term application "System Events" to key code 30 using command down | |
tell i term application "System Events" to keystroke "d" using command down | |
tell i term application "System Events" to keystroke "d" using command down | |
tell i term application "System Events" to keystroke "d" using command down | |
-- Top | |
tell first item of sessions | |
write text "echo MAKE SURE THAT YOU DON'T JUST COPY AND PASTE AND READ THE COMAMANDS BELOW AND REMOVE THE COMMAND 'echo' in front of everything..." | |
write text "echo ssh server.example.org" | |
write text "echo 1" | |
write text "echo screen -r 28177.project_server" | |
set name to "Thin Server" | |
end tell | |
tell second item of sessions | |
write text "echo MAKE SURE THAT YOU DON'T JUST COPY AND PASTE AND READ THE COMAMANDS BELOW AND REMOVE THE COMMAND 'echo' in front of everything..." | |
write text "echo ssh server.example.org" | |
write text "echo 2" | |
write text "echo rails c" | |
set name to "rails c" | |
end tell | |
tell third item of sessions | |
write text "echo MAKE SURE THAT YOU DON'T JUST COPY AND PASTE AND READ THE COMAMANDS BELOW AND REMOVE THE COMMAND 'echo' in front of everything..." | |
write text "echo ssh server.example.org" | |
write text "echo 3" | |
end tell | |
-- Middle | |
tell fourth item of sessions | |
write text "echo MAKE SURE THAT YOU DON'T JUST COPY AND PASTE AND READ THE COMAMANDS BELOW AND REMOVE THE COMMAND 'echo' in front of everything..." | |
write text "echo ssh server.example.org" | |
write text "echo 4" | |
write text "screen -r 26699.project_crawl_queue_1" | |
set name to "resque crawl" | |
end tell | |
tell fifth item of sessions | |
write text "echo MAKE SURE THAT YOU DON'T JUST COPY AND PASTE AND READ THE COMAMANDS BELOW AND REMOVE THE COMMAND 'echo' in front of everything..." | |
write text "echo ssh server.example.org" | |
write text "echo 5" | |
write text "echo screen -r 13106.project_crawl_queue_2" | |
set name to "resque email launch" | |
end tell | |
tell sixth item of sessions | |
write text "echo MAKE SURE THAT YOU DON'T JUST COPY AND PASTE AND READ THE COMAMANDS BELOW AND REMOVE THE COMMAND 'echo' in front of everything..." | |
write text "echo ssh server.example.org" | |
write text "echo 6" | |
write text "echo screen -r 19114.project_mailman" | |
set name to "mailman" | |
end tell | |
-- Bottom | |
tell seventh item of sessions | |
write text "echo MAKE SURE THAT YOU DON'T JUST COPY AND PASTE AND READ THE COMAMANDS BELOW AND REMOVE THE COMMAND 'echo' in front of everything..." | |
write text "echo ssh server.example.org" | |
write text "echo 7" | |
write text "echo screen -r 18583.project_resque_scheduler" | |
set name to "resque scheduler" | |
end tell | |
tell eighth item of sessions | |
write text "echo MAKE SURE THAT YOU DON'T JUST COPY AND PASTE AND READ THE COMAMANDS BELOW AND REMOVE THE COMMAND 'echo' in front of everything..." | |
write text "echo ssh server.example.org" | |
write text "echo 8" | |
write text "echo cd rails/project_muncher; tail -f log/custom.log" | |
set name to "custom_logger" | |
end tell | |
tell ninth item of sessions | |
write text "echo MAKE SURE THAT YOU DON'T JUST COPY AND PASTE AND READ THE COMAMANDS BELOW AND REMOVE THE COMMAND 'echo' in front of everything..." | |
write text "echo ssh server.example.org" | |
write text "echo echo 9" | |
write text "echo cd rails/project_muncher; tail -f log/production.log" | |
set name to "production log" | |
end tell | |
tell tenth item of sessions | |
write text "echo MAKE SURE THAT YOU DON'T JUST COPY AND PASTE AND READ THE COMAMANDS BELOW AND REMOVE THE COMMAND 'echo' in front of everything..." | |
write text "echo ssh server.example.org" | |
write text "echo 10" | |
write text "echo cd rails/project_muncher; tail -f log/mailman.log" | |
set name to "mailman log" | |
end tell | |
end tell | |
end tell | |
-- http://code.google.com/p/iterm2/wiki/AppleScript | |
-- http://code.google.com/p/iterm2/issues/detail?id=559 | |
-- http://www.worldgoneweb.com/2011/iterm2-advanced-features/#comment-20560 | |
ENDSCRIPT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment