My fork of https://gist.github.com/jamesmacfie/2061023e5365e8b6bfbbc20792ac90f8 , adapted to also switch Emacs.
Copy the Python script to the following location:
$HOME/Library/Application Support/iTerm2/Scripts/AutoLaunch/
Create the directory if it doesn't exist. Reboot iTerm2, and say "Yes" if it