open x-devonthink-item links in main window

Small question: external links to DT (x-devonthink-item://) open in DT in a new window, instead of the main one. Is there a way to change this behavior, so links will open in the main window?

You could append ?reveal=1 to the links to reveal the item in the main window.

1 Like

Thanks.

I could’ve sworn that the default behavior was to open in the main window (which is preferable for me), but recently noticed that it doesn’t. Has it always been this way?

Reveal was added. Many Users like to open the files in their own windows, especially because they can open in the current space.

1 Like

I’d vote to have this be an option instead of the default. I very often use “Copy Item Link” to add DT items to my to do list (Things). It’s a little clumsy that these links always open a new window in DT, requiring me to use the “reveal” button, then close the new window.

One solution would be an AppleScript that would put the item URL in the clipboard with “?reveal=1” appended.

Does anyone know the AppleScript to get the x-devonthink-item:// URL of a selected item?

Yes.


tell application id "DNtp" to get the reference URL of (item 1 of (selection as list))

Thanks. I modified one of the default AppleScripts to copy the item link of the selected item + “?reveal=1” to the clipboard. I added it as a toolbar script for easy access.

tell application id "DNtp"
	try
		if not (exists think window 1) then error "No window is open."
		if not (exists content record) then error "Please open a document."
		
		set itemURL to get the reference URL of (item 1 of (selection as list)) & "?reveal=1"
		set the clipboard to itemURL
		
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
	end try
end tell
1 Like

Well done. It’s always nice to roll your own solutions and take control of your computer. :smiley:

@cgrunenberg Are there any parameters that one can add to the link to reveal the item in a NEW window (irrespective of whether there is another viewer window open, etc.)? Thanks!

No, there are currently no such parameters.

Thanks for getting back to me @cgrunenberg

Is there any way we could get that feature in a future DT update? :pray:

For example, in one app that I have, they follow a similar URL scheme but use 0/1 to distinguish whether you’d like to trigger things in a new window or an existing one (e.g., ?reveal=1 vs. ?reveal=0). That might work well with your scheme, too?

Thanks for your consideration!

No promises as it’s the first request of its kind but noted.

2 Likes

This would be a really helpful feature if it could be added

+ 1

The way I’d love to see this feature work is:

  • URL?reveal=1 opens in main window
  • URL?reveal=0 opens in new window
  • Add a preference option to define which behavior is used when “reveal” isn’t specified in the link
1 Like

This depends currently on the preferences - if tabs are enabled, then documents might be opened in the main window if the preview pane is visible. Without a main window or without a preview pane a new document window is opened.

1 Like

I would say that this little detail is very important and I am very glad that it was considered.
Thank you for mentioning them here @cgrunenberg
I expected the page links that I copied open in new window. However I saw that they opened in the main window.

After reading:

I thought that totally makes sense. If you are concentrating on reading one PDF than close the main window and all the page links to that document is going to open in the PDF viewer (new window).
Otherwise, if you are just opening random references to random documents than it is more useful to be able to open them in the main window, as you have all the actions there.

If you additionally want to use RTF links to reveal records take a look at Script: Modify x-devonthink item links to reveal records