Created
June 6, 2014 12:33
-
-
Save aenain/ee759ffb39db5d9fc84c to your computer and use it in GitHub Desktop.
Proof of concept clone of tmuxinator functionality based on iTerm and AppleScript instead.
This file contains 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
#!/usr/bin/osascript | |
set homePath to POSIX path of (path to home folder) | |
set iTermAutomation to load script POSIX file (homePath & "tmuxinator.scpt") | |
set projectDir to homePath & "Desktop/Ruby/growth-republic/iview-prototype" | |
tell iTermAutomation | |
openFullScreenTerminal() | |
activateSessionAndRunCommand("git fetch") | |
splitPaneHorizontally() | |
activateSessionAndRunCommand("bin/rails c") | |
splitPaneVertically() | |
activateSessionAndRunCommand("redis") | |
splitPaneVertically() | |
activateSessionAndRunCommand("bundle exec sidekiq") | |
splitPaneVertically() | |
activateSessionAndRunCommand("bin/rails s") | |
end tell |
This file contains 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
global projectDir | |
-- http://www.iterm2.com/#/section/documentation/scripting | |
on activateSessionAndRunCommand(cmd) | |
tell application "iTerm" | |
tell the last terminal | |
activate current session | |
tell current session | |
write text my goToProjectDir() | |
write text cmd | |
end tell | |
end tell | |
end tell | |
end activateSessionAndRunCommand | |
on splitPaneHorizontally() | |
tell application "iTerm" | |
tell the last terminal | |
tell i term application "System Events" to keystroke "d" using command down | |
end tell | |
end tell | |
end splitPaneHorizontally | |
on splitPaneVertically() | |
tell application "iTerm" | |
tell the last terminal | |
tell i term application "System Events" to keystroke "D" using command down | |
end tell | |
end tell | |
end splitPaneVertically | |
on openFullScreenTerminal() | |
tell application "iTerm" | |
activate | |
tell i term application "System Events" | |
-- new terminal with session | |
keystroke "n" using command down | |
delay 1.0 | |
-- fullscreen | |
keystroke return using command down | |
delay 3.0 | |
end tell | |
end tell | |
end openFullScreenTerminal | |
on goToProjectDir() | |
return "cd " & projectDir | |
end goToProjectDir |
This is very cool. I wish I had found it a few weeks ago. I just released iTermocil which is a command line tool for iTerm which allows you to easily configure sets of panes and commands:
https://github.com/TomAnthony/itermocil
I am a teamocil user, rather that tmuxinator, so iTermocil is compatible with teamocil files.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I implemented this in JS which is new in Yosemite if anyone is curious: https://gist.github.com/pmdarrow/96eb5fcc9c460336fc56.