Skip to content

Instantly share code, notes, and snippets.

@selfire1
Last active December 20, 2022 14:36
Show Gist options
  • Save selfire1/9b69a35840d02405942a3f9739276b3e to your computer and use it in GitHub Desktop.
Save selfire1/9b69a35840d02405942a3f9739276b3e to your computer and use it in GitHub Desktop.
Template for the Templater Obsidian plugin to copy current Obsidian note as markdown link

<%* const title = tp.file.title; const uri = 'obsidian://open?vault=Vault&file=' + encodeURI(title); const fullstring = '[' + title + ']' + '(' + uri + ')'; navigator.clipboard.writeText(fullstring); %>

@mdroidian
Copy link

I think there is a missing ; for the const fullstring ?

I got Templater Error: Template parsing error, aborting. Bad template syntax when I tried it.

This worked for me

<%*
const title = tp.file.title; 
const uri = 'obsidian://open?vault=Vault&file=' + encodeURI(title);
const fullstring = '[' + title + ']' + '(' + uri + ')';
navigator.clipboard.writeText(fullstring); 
%>

@selfire1
Copy link
Author

selfire1 commented Feb 8, 2022

Yes, there is. Thank you!

@FelipeRearden
Copy link

Hello @selfire1 and @mdroidian !!!!

Just to let you guys know that this snippet saved my Obsidian Life 🛟

I was struggling for weeks trying to use templater to change the content of the clipboard.

Thank you very much for sharing this 💙💙💙

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment