🍏 iTerm Applescripting automation is fun.
Plaintext .applescript
files should be compiled into binary .scpt
files to use them happily.
My preference is just to write them in Apple's Script Editor, and compile & export as a script.
If you insist on using your own editor, compile via osacompile -o filename.scpt filename.applescript
.
To create importable libraries, put them in: ~/Library/Script Libraries/
- You may have to create that folder
- These files must be compiled
.scpt
format
Put .scpt
scripts in: ~/Library/Application Support/iTerm2/Scripts/
When you restart iTerm2 you should now see a Scripts menu option.
Go nuts!
Simply put something like the following into your .bashrc
or .zshrc
:
alias six="osascript ~/Libary/Application Support/iTerm2/Scripts/six_sessions.scpt "
With aliases, you can pass args to your scripts, e.g. six 101
.
See this example script for more info.