Skip to content

Instantly share code, notes, and snippets.

@maximegaillard
Last active December 27, 2015 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maximegaillard/7334078 to your computer and use it in GitHub Desktop.
Save maximegaillard/7334078 to your computer and use it in GitHub Desktop.
Applescript to launch Vosae in iterm2 terminals/tabs You must have virtualenvwrapper properly configured with in your vosae-app postactivate script something like cd ~/my_folder/vosae-app/ and in your vosae-web postactivate script something like cd ~/my_folder/vosae-app/
#!/usr/bin/osascript
-- Applescript to launch Vosae in iterm2 terminals/tabs:
--
-- Run from terminal with `osascript` or just ./<<script>>
-- Dont unfocus with the mouse/keyboard while executing. the script.
-- Recomended to go full screen (CMD + Enter) if <zoomout> attributes used.
-- Change myTermWindow and myItem(s) as desired.
--
--
-- Source https://github.com/luismartingil/scripts/blob/master/iterm_launcher02.applescript
tell application "iTerm"
-- First tab
set myItem1 to {}
set myItem1 to myItem1 & {{color:"blue", cmds:{"elasticsearch -f"}, name:"elasticsearch", trans:"0.2", split:"h"}}
set myItem1 to myItem1 & {{color:"blue", cmds:{"cd ~/Sites/git/vosae-app/www/", "./mongodb.sh start"}, name:"mongo", trans:"0.2", split:"h"}}
set myItem1 to myItem1 & {{color:"blue", cmds:{"redis-server"}, name:"redis", trans:"0.2", split:"h"}}
set myItem1 to myItem1 & {{color:"red", cmds:{"workon vosae-app", "grunt"}, name:"grunt app", trans:"0.1", split:"v"}}
set myItem1 to myItem1 & {{color:"green", cmds:{"workon vosae-app", "cd www/", "python manage.py runserver 8000"}, name:"django app", trans:"0.1", split:"v"}}
-- Second tab
set myItem2 to {}
set myItem2 to myItem2 & {{color:"green", cmds:{"workon vosae-web", "cd www/", "python manage.py runserver 8001"}, name:"django web", trans:"0.1", split:"h"}}
set myItem2 to myItem2 & {{color:"red", cmds:{"workon vosae-web", "grunt"}, name:"grunt web", trans:"0.1", split:"h"}}
set myTermWindow to {myItem1, myItem2}
set myterm to (make new terminal)
tell myterm
repeat with n from 1 to count of myTermWindow
launch session n
repeat with i from 1 to count of (item n of myTermWindow)
-- Lets set the properties of the actual tab
tell the last session to set name to name of (item i of (item n of myTermWindow))
tell the last session to set background color to color of (item i of (item n of myTermWindow))
tell the last session to set transparency to trans of (item i of (item n of myTermWindow))
-- Lets execute the commands for the tab
repeat with cmd in cmds of (item i of (item n of myTermWindow))
tell the last session to write text cmd
end repeat
-- Split the pane in a "D" (vertical) or "d" (horizontal) way
if i is less than (count of (item n of myTermWindow)) then
if "h" is split of (item i of (item n of myTermWindow)) then
set split_str to "D"
else if "v" is split of (item i of (item n of myTermWindow)) then
set split_str to "d"
else
error
return
end if
tell i term application "System Events" to keystroke split_str using command down
end if
end repeat
end repeat
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment