dragging icns file onto get info window to add an icon to the app

Tiny Tip – AppleScript to Launch Terminal in Current Finder Directory by Frank Vos

Last week I talked about using the proxy icon in Finder windows to drag into a Terminal window so I could quickly change directory quickly without typing the full path and without having to escape out the spaces between words in my directory paths.

Frank Vos wrote in with a great tip on how to make this even easier. I have to warn you that when I started reading his idea, my first thought was, “This is going to be way more complicated than just dragging the proxy icon.” But when I got to the end, I realized it’s easy and magical when you’re done.

So the problem to be solved is that you have a Finder window open right where you need to work in Terminal. At the top level, you’re going to enter four lines into a script, save it with a name, give it a cute icon and then drag it into the toolbar of the Finder window. After you’re done, when you’re in a folder in Finder that you want to open in Terminal, all you do is click your cute icon, and boom, you’re in Terminal in that directory!

Now that you know how easy this is, let’s go through Frank’s detailed instructions.

Launch the Script Editor application which is buried in Applications/Utilities. Then enter the following four lines to get to the current path in Finder, open Terminal and open that directory.

tell application "Finder"
    set myDir to POSIX path of (insertion location as alias)
    do shell script "open -a \"Terminal\" " & quoted form of myDir 
end tell

Once you’ve entered the code, you can save it out of ScriptEditor as an app. Frank named his OpenTerminal.app. (Side note: Frank is from The Netherlands and so his screenshots are in Dutch. I think that’s really cool because by comparing my Save As dialog box to his, I have learned that “Options” is Opties” in Dutch, and even better, “Show startup screen” is “Toonopeningsvenster”! How fun is that? Ok, back to Frank’s instructions.

Save Script as App
Save Script as App (in Dutch!)

Frank provided a cute blue icon file with the classic prompt on it. I’m adding it to the show notes as a zip file because .icns files get weird sometimes when you need to send them around.

Download cute icon Prompt.icns.zip

Drag Cute icns File Onto Get Info Window for Your App
Drag Cute icns File Onto Get Info Window for Your App

You can use your own icon file or even a plain PNG if you’re not comfortable downloading a zip file from a website. In any case, once you have the icon file you like, select your shiny new OpenTerminal app and select Get Info from the File menu. This will show you the generic script icon at the top. Drag your cute icon file on top of it and now your app has the cute icon.

The last step is what really makes it magical – open a Finder window and hold down the command key and drag the app up into the Finder toolbar and drop it when it’s positioned where you want it.

Drag App Into Finder Toolbar with Command Key Down
Drag App Into Finder Toolbar with Command Key Down

Ready to test? You can now click on the icon of the App that’s available on every Finder window and a Terminal window will be opened with the directory that’s displayed in the Finder.

Buried Directory in Finder
Buried Directory in Finder
Terminal Opened to Buried Directory
Terminal Opened to Buried Directory with a Single Click

I love Frank’s tip because it took me maybe 30 seconds to set it up and now I will forever have it available at my fingertips. And I learned a little bit of Dutch along the way. Thank you so much, Frank, for taking the time to figure this out, share it with us and give us detailed instructions.

3 thoughts on “Tiny Tip – AppleScript to Launch Terminal in Current Finder Directory by Frank Vos

  1. Claus - November 13, 2021

    This is awesome, thank you so much for sharing this very cool tip.

  2. Dan - May 20, 2024

    This is so cool.
    I assigned it to a quick action and then a shortcut to it.

    Finally we can almost have the same functionality as in KDE’s Dolphin.

  3. Allison Sheridan - May 20, 2024

    I’m glad you commented on this, Dan. I had forgotten all about it because, also from the Netherlands, showed us that you can write click on the folder in the path bar and choose Open in Terminal. Well that is pretty easy I think I would like to go back to using this little Apple script. or now that I know how to write shell scripts, maybe I will do it in that!

    Also, great irony about KDE.

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top