There’s a way to fetch the already encoded file://
link via Finder’s AppleScript. I’ve set mine to auto expand wherever I type ;flink
(via Keyboard Maestro typed string trigger).
tell application "Finder"
set theItem to the first item of (get selection)
set theURL to the URL of theItem
return theURL
end tell
Here’s how it looks like in Keyboard Maestro
Got that idea from @MacSparky’s TextExpander tip for executing AppleScripts via text expansion. From there, I’ve learned some AppleScript and looked for ways to fetch links to the current item in Finder, Things, Obsidian, Safari’s frontomost tab URL, etc.
Some are really wonky, but the vast majority are very straightforward requiring almost not intervention on the scripts whatsoever. So here are a few more for anyone who’s looking for something like this and looking for inspiration.
If you want to use Keyboard Maestro, just copy the instructions from the screenshot and the scripts bellow into the Execute AppleScript textbox. I also recommend using the same ;Xlink
grammar to help memorizing them (for me, Things is a ;tlink
, Safari a ;saflink
, Obsidian an olink
, Evernote a ;elink
, etc.)
I know Hook has a way to do this (invoking it with the source item open and hitting ⌘+C
to get the link and then pasting it into the target app), but I find typing these text strings to be faster and not depending on a third-party app to tie them together.
Things
tell application "Things3"
set lista to selected to dos
set theItem to the first item of lista
set idItem to id of the first item of theItem
set linkThings to "things:///show?id=" & idItem
return linkThings
end tell
Safari
For the plain URL:
tell application "Safari"
tell window 1
set safLink to URL of current tab
end tell
end tell
return safLink
If you rather have a markdown input, I use this:
tell application "Safari"
tell window 1
set safLink to URL of current tab
set titulo to name of current tab
end tell
end tell
return "[" & titulo & "]" & "(" & safLink & ")"
Evernote
tell application "Evernote Legacy"
set lista to selection
set nota to first item of lista
set titulo to title of nota
set elink to note link of nota
return titulo & linefeed & elink
end tell