/iterm-scripts

iTerm Applescripting automation is really fun, and really powerful. And not easy.

Primary LanguageAppleScriptThe UnlicenseUnlicense

iTerm Scripts

🍏 iTerm Applescripting automation is fun.

Compiling Applescript

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.

Script Libraries

To create importable libraries, put them in: ~/Library/Script Libraries/

  • You may have to create that folder
  • These files must be compiled .scpt format

iTerm2 Scripts

Put .scpt scripts in: ~/Library/Application Support/iTerm2/Scripts/

When you restart iTerm2 you should now see a Scripts menu option.

Go nuts!

Bash Aliases

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.