Get UUID Link to a Draft

I know this is a foolishly simple script and might be unnecessary, as there is probably a setting I am missing in Drafts, but I asked ChatGPT to write a script to get the link to the current draft in Drafts so that I could then assign a keyboard shortcut.

This is super useful to me because I love linking to drafts. At the risk of highlighting my ignorance at missing a built-in setting, I am sharing in case anyone else would like a keyboard shortcut to get a link to a draft.

2 Likes

Love it! Crazy that ChatGPT can generate these things.

As is typical of code, there’s lot of ways to skin a fish, but just so it’s out there, the “easy” way to do this would be:

app.setClipboard(draft.permalink)
1 Like

As another option, did you know that you can also do it entirely scriptless?

The TAD-Copy Draft Link in the ThoughtAsylum - Export/Import/Share action group uses a copy to clipboard action and a Drafts template tag.

it uses [[draft_open_url]], so I do realise an update to use [[permalink]] is in order - duly added to my 2024 task list.

Looking in the directory, a standalone action by @agiletortoise action, Copy Link uses the same approach.

1 Like

Thanks for pointing out the better way to do it!

Drafts is the primary motivation for me to want to learn Javascript. I have started and stopped a few times now with reading books and going through online courses to learn. My self-guided experiments immediately run into roadblocks.

ChatGPT has been an awesome tutor/guide on this most recent attempt to learn to code. Maybe it broke down the code the way it did based on my novice nature, or maybe it is just dumb. :slight_smile:

1 Like

Thanks @sylumer for the direction!

I knew I had to be missing something out there, turns out I was missing multiple things.