Recently, I stumbled on the Textmate droplet by Henrik Nyh allowing me to quickly open a file or a folder in Textmate by dragging it to the Finder toolbar. Since I had just setup iTerm2 and learned to script it with AppleScript, I figured I’d put the two together and create my own iTerm2 droplet. Since this was going to be my first droplet, I searched for some guidance and found a great article by Jarel Remick which covers the subject of Finder productivity and droplets in great depth.

Creating the droplet

A Finder droplet is really an AppleScript which interacts with the Finder in order to obtain either the path to the current directory or the selected file and with another app in order to launch it or interact with it. This AppleScript is then saved as an application which we will add to the Finder menu by a simple drag and drop.

My droplet is simple : it will get the path to the directory opened in the current Finder window. Launch iterm if itsn’t already running and cd into that directory.

So, here is the code behind my droplet :

tell application "Finder"
set currentPath to (POSIX path of (target of front window as alias))
end tell

tell application "iTerm"
tell the last terminal
launch session "Default"
tell the last session
set name to currentPath
write text "cd " & currentPath
end tell
end tell
end tell
end try


Customizing the droplet

At this point, you can save your code as an application from the AppleScriptEditor and drag the resulting file to the Finder toolbar. Click it, and the current folder is opened in iTerm.

Still, before adding this to my Finder’s toolbar, I customized it with a little terminal icon. Mac OS really make this simple. Simply find an icon you like and open it using Preview. Copy the image to clipboard (CTRL-C). Then, select the Application you just created with AppleScriptEditor and right click to display the file info (or use CTRL-I). Select the icon at the top left of the window (it will be selected in blue) and paste your image (CTRL-V).

That’s it. This step was surprisingly simple.


Installing the droplet

Nothing complicated in this step : simply drag your application (or droplet) to the Finder’s toolbar. Click it, iTerm will open and your pwd will be set to the current Finder’s window directory. Handy.



If you simply want to download my version of the droplet to not go through these steps yourself, click here. If you would like to use more droplets. start your hunt right here.

Filed under: Computing, Mac OS X, Système

Tagged with: , , , , , , , , ,

Liked this page?

Tweet it

Subscribe to the RSS feed or sign up for the newsletter now.

Posts related to Creating a Mac OS X Finder Droplet for iTerm

3 Comments to "Creating a Mac OS X Finder Droplet for iTerm"

  1. Comment by Anon on February 23, 2012 at 12:11 pm Reply


    Re line 12 – Your editor has escaped the ampersand character to its html entity (& amp 😉 so someone pasting the code in the AppleScriptEditor would get a compile error as it’s not concaternating the strings. Just needs a reformat to show just the ampersand.

    • Comment by shalfon on February 26, 2012 at 10:08 am Reply

      Thanks for pointing this out. I updated the post to correct this.

  2. Comment by GApatriot on February 20, 2013 at 6:16 pm Reply

    Thanks for this tip.

    I found that the code had one issue for me, it didn’t like spaces in the folder names.
    I changed line 3 to look like this:
    set currentPath to (quoted form of POSIX path of (target of front window as alias))

    instead of:
    set currentPath to (POSIX path of (target of front window as alias))

    I had to add “quoted form of” so that the line 12 ends up a path with single quotes around it, thereby not breaking the CD command without an escaped space in folder name.

Name (required)

Email (required)


Leave a Reply

  • About Me

    photo of Samantha Halfon Samantha Halfon
    Software Engineer
    blueKiwi software
    Paris, France
    I enjoy playing with my computer(s), listening to Bob Dylan (and related artists) and watching movies (especially if they were directed by Martin Scorsese or John Cassavetes). Sometimes, I play a little guitar... If not doing any of the above, I am either riding a small red bike around Paris, or, making videos. About my videomaking please check out World Wide Angle and its blog.