Hook link to bring up a terminal in selected folder?

I’ve now got Hook coordinating all my different projects using TextEdit documents of links. It works well.

The only regular activity left that I want to make easier is bringing up Terminal in an appropriate directory. I do this a lot.

I can create a HookLink to the directory, click on it and control-click the path at the bottom of the finder window ‘new terminal in folder’, but that’s painful and leaves extra windows around. I would like it to be a single click. I don’t mind having to edit URLs manually to achieve it.

I think there may be a theoretical problem with Hook’s model: one document type (folder, in this case), one action. So there’s no UI paradigm for saying ‘Given you’ve selected a folder, now select what you want the HookLink to do with it’; all the UI options, like ‘copy all links’, appear hard coded. But as I said above, I’d be happy to hack the link. Something like:

[Terminal in Documents](hook://file/hgaaJP9F3?action=BringUpATerminal&n=Documents)

Might there be any way to do that?

Best,

Charles

Hi Charles,

Thank you for using Hook and sending us this question.

Currently, there is not an easy way to open terminal with a Hook link. We could do this with some pain of tweaking AppleScripts in Hook->Preferences, but I am not sure that it worth the effort. We will consider the request in our overall product roadmap, as we have a few features in our pipeline to address the similar request.

In short term, you could create a service keyboard shortcut to open “new terminal in folder”. This will save you from navigating finder context menu of Finder. To create service keyboard shortcut, go to System->Preferences->Keyboard->Shortcuts Tab->Services, find “Files and Folder” section and edit shortcut for New Terminal At Folder.

Hope this helps.

Brian Shi

Development Manager
CogSciApps Corp.

Get a copy of PathFinder and configure it to open instead of Finder. PathFinder has a terminal module that can open next to the current directory.

Hi Brian,

Great idea to use a service and shortcut, but that particular service needs you to have the folder selected. So I needed to go up one folder, then select the folder I’d just left, then press the shortcut combination. Not faster.

But Automator does allow us to create new services. So I created one (Automator calls it a Quick Action), taking no input, and put in an action with the following Apple Script:

on run

tell application "Finder" to set currentDir to (target of front Finder window) as text

set a to "open -a 'Terminal' " & (quoted form of POSIX path of currentDir)
do shell script a
tell application "Terminal" to activate

end run

One can then give the service a name with Save…, (I used ‘Finder Terminal’), then one can assign a shortcut key to that service as you described. (Note after setting up a shortcut key you need to invoke the service using the menu before the shortcut key will work). And it’s two clicks to get to the terminal.

  • Charles
1 Like

Hi Chales,

Your solution is awesome. I am glad your solution worked out for you.

Brian

LaunchBar also provides native functionality allowing you to select a folder and open a Terminal window at its location. It’s so fast and easy it feels like you think it and it happens.

Hi @capcrime, I’m trying hard, but I can’t see an easy way to get LaunchBar to behave as you describe. Can you explain what you do?

So, I first navigate to the target folder, hit Tab, then type T-E-R-M and hit the “New Terminal at Folder” option.

Ah, so do you navigate to the folder within LaunchBar, then? I was assuming you first selected a folder in the Finder, and then activated LaunchBar, and so on.

Navigating to folders in LaunchBar is something that doesn’t really work for me, for some reason.

It’s worth getting the hang of as the efficiencies gained are substantial. Trick is to narrow your search index to those directories you want to be able to quickly navigate to.

Yes, you navigate to the folder within Launchbar.