From Finder : How to open terminal to the current directory?

Hello,

I'm trying to find a way to open apps and supply the current folder of the Finder path.
Is there any documentation about this?

I have the same problem each time I want to launch a program, I need to know which path the Finder is currently set on.

Thank you in advance,

Micaël

You can use the predefined action "Open Active/Selected Folder With Specific App", then assign Terminal as app.

Using AppleScript:

tell application "Finder" to return the POSIX path ¬
               of (its insertion location as alias)

Or:

tell application "Finder" to tell the front Finder window to if ¬
       exists then return the POSIX path of (its target as alias)

Hi there,

might be a bit late to the party but I figured out a way for me using Ghostty.

I set Keyboard Trigger CMD Shift T to only work when extended condition active_app_name == "Finder" is met.

Then run Apple Script from @CJK which I extended using Ghibidi and some docs I found for the ghostty:

tell application "Finder" to set currentPath to the POSIX path of (its insertion location as alias)

-- Open a new Ghostty instance with the working directory set to currentPath
do shell script "open -na Ghostty --args --working-directory=" & quoted form of currentPath

Finder-Path-to-new-Ghostty-Window.bttpreset (3.9 KB)

One drawback seems: Opens the App as a new instance. So when you then close the window when you are done it is an additional entry in your app switcher so you would have to close it with CMD + Q.

Might dig into this in the future when I used the workflow more often and get annoyed by it so that I want to open the path in a new Ghostty-Tab instead of -Window

Blocks Keyboard-Shortcuts like opening last closed tab in browsers.
NewGhosttyInstancewithcurrentFinderpath.bttpreset (6.3 KB)

Solved it with a condition.
Also -na as an argument needs to be there to open ghostty as a new instance - if you don't do that and have a command currently running or on another machine this causes problems and won't work.

Ghostty also doesn't seem great with regards to scripting. Other Terminal emulators are better here: