If you happen to be an Emacs user on MacOS AND want to be able to link to notes inside your obsidian vault inside of an org-mode document (who wouldn’t, right?), here’s some code for you. I use applescript as an intermediary because it works out of the box.
;; obsidan link handling for obsidian:// links
(defun org-obidian-link-open (slash-message-id)
"Handler for org-link-set-parameters that opens a obsidian:// link in obsidian"
;; remove any / at the start of slash-message-id to create real note-id
(let ((message-id
(replace-regexp-in-string (rx bos (* "/"))
""
slash-message-id)))
(do-applescript
(concat "tell application \"Obsidian\" to open location \"obsidian://"
message-id
"\" activate"))))
;; on obsdian://aoeu link, this will call handler with //aoeu
(org-link-set-parameters "obsidian" :follow #'org-obidian-link-open)
include this after org is loaded in your private configuration
Thank you for this solution! I was looking for something like this for a non-mac environment. I took your solution and edited it to work on my Ubuntu that’s running off of WSL. Works like a charm and lets me have the best of both worlds!
Here’s the code for any future people wanting to do the same on their Linux or Linux on WSL install of emacs:
;; obsidan link handling for obsidian:// links
(defun org-obsidian-link-open (slash-message-id)
"Handler for org-link-set-parameters that opens a obsidian:// link in obsidian"
;; remove any / at the start of slash-message-id to create real note-id
(let ((message-id
(replace-regexp-in-string (rx bos (* "/"))
""
slash-message-id)))
(async-shell-command (concat "Obsidian.exe \"obsidian://" message-id "\""))))
;; on obsdian://aoeu link, this will call handler with //aoeu
(org-link-set-parameters "obsidian" :follow #'org-obsidian-link-open)
I’ve been playing with Hyperbole in Emacs (https://www.gnu.org/software/hyperbole/) and using your MacOS code works wonderfully there. I just put in the URL of my Obsidian document anywhere in an Emacs file and M-return will open it in Obsidian