This script opens a new iTerm tab at your currently active Finder window's directory. It opens a new iTerm window there instead if you don't have iTerm running yet.
Referenced from the original tutorial written by Peter Downs at http://www.jofu.org/blog/2016/02/04/open-iterm-tab-from-finder-by-shortcut.
You just want a short script with minimal configuration to get this shortcut working. For a more fully-featured solution, please use "iTerm2 Finder Tools" which you can download from Peter Down's GitHub repository.
It should work for most other MacOS / iTerm2 versions, but this is my setup:
- MacOS X 13.3 High Sierra
- iTerm2 Build 3.1.5
- Run Automator. It'll prompt you to create a new workflow / application / service ...
- Select Application and click on Choose
- On the left sidebar, go to Utilities > Run Applescript
- Double-click on Run Applescript to create a new Applescript file
- Copy & Paste the code in
iterm_shortcut.scpt
below into the Applescript file - Save the application somewhere in a local directory
- Open Finder and navigate to the directory where you saved the application
- Hold down command+option and drag & drop the application into your Finder window's toolbar as such:
- Click on the application and press command+i to bring up its
Get info
page - Find your original iTerm app in your
/Applications
folder and bring up itsGet info
page too - Click on the iTerm app's icon
- Press command+C to copy the iTerm app's icon
- Click on the iTerm shortcut application's icon (in its
Get info
page) and paste with command+V like this:
- [PENDING] It seems that if I click on the red
x
close button on iTerm and try to invoke the shortcut again, it crashes and instead opens a new separate window.