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.
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.
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.
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.
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.