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 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
#!/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 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
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 |
I implemented this in JS which is new in Yosemite if anyone is curious: https://gist.github.com/pmdarrow/96eb5fcc9c460336fc56.
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
@Kayne how do you run the script? I've quickly checked on Yosemite (after upgrade, not clean install though) and I am no longer able to run the config script directly from shell, but running it like this
osascript ~/sample_config.applescript
does not lead to reproducing the error. Have you tried to recompiletmuxinator.scpt
using AppleScript Editor? [http://stackoverflow.com/questions/23398435/applescript-error-10810] suggests that either iTerm application could not be found or the process table is full. You can try to replacetell application "iTerm"
withtell application "Applications:iTerm.app"
(set the correct path to iTerm.app file, in my case it is in /Applications/iTerm.app).Let me know if that helps :)