Last active
December 22, 2015 05:48
-
-
Save FranciscoG/6426028 to your computer and use it in GitHub Desktop.
iTerm2 AppleScript script Note: This is very specific to my workflow but you should be able to see how AppleScript works and tweak it for your own needs I use it in tandem with some bash scripts functions in my .bash_profile that go to certain folders.
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
tell application "iTerm" | |
activate | |
#if a terminal exists, use that. if not, create a new one | |
try | |
set _term to current terminal | |
on error | |
set _term to (make new terminal) | |
end try | |
tell _term | |
#I like to start a new tab and keep the 1st one open just in case I need more space | |
launch session "Default" | |
#I'm going to be splitting this into 4 panes so I'm making it real big | |
set number of columns to 245 | |
set number of rows to 55 | |
(* | |
The next step gets repeated a couple times. It basically does this: | |
1. rename the session pane | |
2. runs my bash script function that jumps to a specific dir. (example: "contra" runs "cd ~/projects/contra") | |
3. runs a command to watch for changes to certain files and auto-compile/min/concat | |
*) | |
tell current session | |
set name to "Contra" | |
write text "contra" | |
write text "grunt watch" | |
end tell | |
(* | |
'tell i term application "System Events" to keystroke "D" using command down' | |
This command tells the application to mimic that key combination: shift+command+d | |
In that line, notice that there is a capital 'D' but not the word "shift" | |
That's because a capital 'D' already stands for "shift+d" | |
This one splits the current session window horizontally | |
bottom automatically becomes active "current session" | |
*) | |
tell i term application "System Events" to keystroke "D" using command down | |
tell current session | |
set name to "JT SASS" | |
write text "jtcss" | |
write text "compass watch" | |
end tell | |
#split the bottom pane vertically, Bottom right pane becomes active "current session" | |
tell i term application "System Events" to keystroke "d" using command down | |
#do nothing now, I'll come back to this one at the end | |
#switch to next pane which is the top one | |
tell i term application "System Events" to keystroke "]" using command down | |
#split the top vertically, top right becomes active | |
tell i term application "System Events" to keystroke "d" using command down | |
tell current session | |
set name to "JT JS" | |
write text "jtjs" | |
write text "grunt watch" | |
end tell | |
#switch to previous pane which is bottom right and I will use that for my input | |
tell i term application "System Events" to keystroke "[" using command down | |
tell i term application "System Events" to keystroke "[" using command down | |
end tell | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment