Obsidian link not working in *.hook file (updated: make sure the extension is really .hook, and Finder>Open In is Hook)

Hi,

I am using latest version of Hook (3.4.1, script 193). I tried to create a URL link to a page in Obsidian (latest version 13.23), for example, it looks like this:

[TOC Hold >](obsidian://open?vault=obsidian_sandbox&file=TOC%20Hold%20%3E)

If I create a plain text file and save it as *.hook file with only the above link, Hook can’t open the link – please see the attached screenshot for error message

However, if I save the *.hook file with the following instead:

obsidian://open?vault=obsidian_sandbox&file=TOC%20Hold%20%3E

The hook file works and I can open the file in Obsidian.

I suppose it is a bug?

Best,
Jake
Screen Shot

Thank you. We’ll have a look

I’ve done some testing and found that when Spotlight, Launchbar and Safari launch obsidian’s URLs that have .txt extension, the files are actually opened in the default .txt file app. On my system that is BBEdit.

So this is not a Hook specific thing.

If you put obsidian://open?vault=obsidian_sandbox&file=TOC%20Hold%20%3E in Spotlight you’ll get a similar result, I suppose. Also if you put obsidian://open?vault=obsidian_sandbox&file=TOC%20Hold%20%3E you’ll get a similar result. Meaning: it will open in a .txt editor.

Opening the markdown link creates an error, probably due to the ping pong below.

Normally the solution is to set the “open in” for the file to be the app you want to open it in. But that can’t be done with obsidian which is an electron app, not fully integrated with macOS frameworks.

(Do the Obsidian folks have any plans to create a macOS native version of their app?)

Since the URL is obsidian:// , it looks to me like Obsidian that is passing the request onto macOS, and macOS passes it on to the default app.

I don’t use obsidian enough. I’ll contact an obsidian liaison. And a developer here will have a look. Maybe there’s something we can do with the “Open In” script for Obsidian.

Many Hook users also use obsidian. If anyone wants to become an Obsidian liaison please let us know here or by PM.

2022-02-04 17:49: correction of a previous version of my reply: when opening the link from BBEdit it does not work either. This suggests it’s not really a bug with Hook but an issue with Obsidian. I also added a note above about “Open In”

1 Like

Thanks for looking into the issue. However, I don’t understand why it is a problem related to .txt extension.

I guess I did not explain my issue clearly so I am trying to elaborate.

I copied a markdown URL link to an Obsidian file through Hook. Then I opened a blank file in Sublime Text, pasted the markdown URL

[TOC Hold >](obsidian://open?vault=obsidian_sandbox&file=TOC%20Hold%20%3E)

into the file, then saved it as Testing1.hook. When I double clicked the Testing1.hook file, it didnt work and shown me the attached screencap in my first post.

I repeat the above, but used the copy URL function of Hook instead of markdown URL link function – obsidian://open?vault=obsidian_sandbox&file=TOC%20Hold%20%3E. I created Testing2.hook and Hook can successful open the file and bring me to the file in Obsidian.

I can use the same method to copy a markdown URL link from Zotero and create a working .hook file – Hook can open the file and bring up Zotero with the entry highlighted.

Also, the file in Obsidian I am trying to create a hook link is a .md file. In addition, if I paste

obsidian://open?vault=obsidian_sandbox&file=TOC%20Hold%20%3E

into Spotlight, Spotlight can call up Obsidian and open the file.

Since the .hook can work perfectly with a pure URL link to an Obsidian file but not a Markdown URL link, I believe that it is a problem related to Hook and its interpretation to markdown link to Obsidian instead.

I don’t think .hook files normally contain anything but the URL, so sounds to me the issue is you’re creating a malformed .hook file by hand.

Hello,

I think it is possible to put either a URL or markdown format URL link in the .hook file, provided that both the URL can be resolved by the system without Hook app.

From the instruction here: Make Hookmark File – Hookmark

They can contain any URL (address) that your macOS instance can resolve. .hook files can contain links to files and folders, of course. But the URL scheme can be anything macOS can handle, such as omnifocus:/// , craft:///, x-devonthink-item:/// or x-nvultra: . If your Mac has an app that can open the URL, you’re good to go. For instance, DEVONthink 3 will open x-devonthink-item: links.

So, for example, you can put the following Markdown link in a “.hook” file:
[Make Hook File](https://hookproductivity.com/help/hook-window/make-hook-file/)
If you double click on that .hook file, Hook will ask macOS to open that web link.

1 Like

You’re right.

Maybe it’s the ‘>’ then? If you remove that does it work? In Markdown that’s a reserved character that needs escaping.

Thanks for the suggestion. I tried and it does not help, still giving me the same error.

the > is fine per this test

  1. created file called test 6359 plain >.hook
  2. pasted this in it test 6359 plain >.txt in BBEdit.
  3. clicked on .hook

worked. In my case the default app for .txt is BBEdit.

so “>” in .hook files containing Markdown links does not cause a problem.

similarly, double-clicking on a .hook file with a markdown link, such as this:
TestObsidian >
works fine, whether it is manually created or created by Hook.

I can replicate that opening a .hook file manually created with a Markdown link to an Obsidian object fails, whereas one that is constructed by Hook (using Make Hook File) works. That’s weird. will look again tomorrow, it’s late here.

Comparing the manual file vs the Hook generated one, is one formatted as plain text and the other rich text if you open them in a raw file reader?

In my case,I create .hook files with BBEdit, so it’s plain text.

(Speaking of which, I blogged about BBEdit: A powerful, highly linkable, text editor for creative work and note-taking recently.

retracting my earlier comment here (post 12). I was testing with Hook 3.5, and I need to confirm something with a developer here. Will update this one later.

Thanks for working on the problem.

Some more information:

If I copy a markdown URL link to an Obsidian file through Hook, and make a hook file, I see the error message as I show in my 1st post.

If I copy a markdown URL link to a Zotero pdf through Hook, and use Sublime text to open the hook file created in the above step, and replace with the Zotero markdown URL, save it. Then the same Hook file now works, and will bring up Zotero and show me the target pdf.

If I create a URL link to the same Obsidian file through Hook, it works and can call up the Obsidian app and open the target file, no matter I am creating a new Hook file, or again editing the existed Hook file in the above step.

1 Like