1

I cannot get the default Finder "New Terminal at folder" service to work, no matter what. I've tried every trick I could find online.

So I created a new service and it appears in the Services list, but again, cannot get it to appear in the actual services menu nor does mapping a hotkey work.

The kicker is that this exact service was working for the last few months with no issues. Suddenly just stopped working. I haven't updated the OS or anything.

I'm on Sierra.

The script is below:

on run {input, parameters}

    tell application "Finder"

        set myWin to window 1

        set theWin to (quoted form of POSIX path of (target of myWin as alias))

        tell application "Terminal"

            activate

            tell window 1

                do script "cd " & theWin

            end tell

        end tell

    end tell

    return input

end run

I really need this service to work, it saves me so much time and I really hate how it's not a reliable os feature.

1 Answer 1

1

macOS Sierra has two built-in Terminal Services, New Terminal at Folder and New Terminal Tab at Folder.

Go to System Preferences > Keyboard > Shortcuts > Services > Files and Folders, and check one or both and add a keyboard shortcut if you’d like.

Then in Finder you can select a Folder, right-click and select the service from the Services context menu, or from the Finder > Services menu or use the keyboard shortcut if assigned.


There’s no need to use AppleScript unless you really want to.

Here's some example AppleScript code that works of me:

try
    tell application "Finder"
        set theTargetPath to quoted form of (POSIX path of (target of front window as string) as string)
    end tell
    tell application "Terminal"
        do script "pushd " & theTargetPath & "; clear"
        activate
    end tell
end try

Note: The example AppleScript code is just that and aside from the use of a try statement, does not employ any additional error handling and is meant only to show one of many ways accomplish a task. The onus is always upon the User to add/use appropriate error handling as needed/wanted.

2
  • I do not have Services > Terminal, only Services > Files and Folders. I have checked both and added a shortcut, and it still will not appear in the menu. I restarted my computer, and the AppleScript option is now working. No idea why it suddenly stopped working.
    – Karric
    Feb 2, 2018 at 15:57
  • @Karric, Yes, it was supposed to be "Files and Folders", I just had Terminal on my mind. That said, why not use the built-in services over rolling your own? Feb 2, 2018 at 16:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .