ryanjamurphy / DEVONlink-obsidian

Open notes indexed in DEVONthink in, well, DEVONthink
92 stars 3 forks source link

[Feature Request] Search DevonThink within Obsidian and paste link or content #3

Closed derekvan closed 3 years ago

derekvan commented 3 years ago

This is a huge request, so I totally recognize if this isn't of interest to you. However, as I was playing around with the Citations plugin for Zotero, I was thinking how useful it would be to have a similar search interface within Obsidian for DevonThink--to be able to pull up a search window and find a file in DevonThink, then paste the link (with markdown formatting) in the open note, or even to past the content of the file (if it's a text file) along with a link back to the DT file.

I have no idea how much work this might be in Obsidian. I was hoping since there is a search plugin for Alfred that a plugin for Obsidian could similarly hook into DevonThink.

ryanjamurphy commented 3 years ago

Sorry for the delayed reply.

I have a Keyboard Maestro macro for this, but it's actually quite finicky. The trick is that performant search of DEVONthink databases can be really tough to do. What I was doing was regularly generating an index of all items, saving it as a text file with each item's name on a new line, then selecting from that list and inserting the item-link of the resulting selection.

Maybe, though, it'd make sense to add a command to DEVONlink that takes input from a modal and then searches DEVONthink for whatever you put into that modal. Then you could just get the link, switch back to Obsi, and paste it in.

Not the same as what you were thinking, though, obviously. Thoughts?

derekvan commented 3 years ago

Thanks for responding here. I think your move to KM is probably a good one here. Doing this with other tools is probably the way to go. I've been getting by with an AppleScript run through KM that grabs whatever's selected in DT and pastes as markdown links (with the file name in the brackets and the x-devonthink link in the parens). There's also this Alfred workflow that works (https://github.com/mpco/AlfredWorkflow-DEVONthink-Search), and you can copy the x-devonthink link with it, but not in markdown format with the file name (and I can't figure out how to adjust that in the Alfred workflow area--I don't see any scripts that support that copy function). Best of both worlds would be ideal: search in Alfred, even pop a few things in the "file buffer", then action them to put list of markdown formatted links on the pasteboard. I'm certainly not assigning this work to you of course, but if you knew of any pointers to get there I'd love to tinker around with this.

ryanjamurphy commented 3 years ago

Interesting. There's actually a solution to this in the Alfred workflow you linked to, but the PR hasn't been accepted by the project owner, looks like.

Replace lines 92-93 in the workflow's search.js file with:

                "cmd": { "valid": true, "arg": itemUUID, "subtitle": "🏷 " + itemTagStr },
                "alt": { "valid": true, "arg": itemUUID, "subtitle": "Reveal in DEVONthink" },
                "shift": { "valid": true, "arg": "[" + itemName + "](" + "x-devonthink-item://" + itemUUID, "subtitle": "Copy Markdown link" }

Then, add the following as a Run Script action of type /usr/bin/osascript following the workflow's dnt script filter:

on run argv
  set theQuery to item 1 of argv
  tell application "System Events"
    keystroke argv
  end tell
end run
derekvan commented 3 years ago

thanks Ryan, I was able to get this to work. Appreciate you tracking it down.