DEV Community

AIRabbit
AIRabbit

Posted on

Powerful Obsidian integration with URIs

Obsidian's simplicity and thriving ecosystem have made it a favorite for many, myself included. A key feature that initially caught my attention was the Obsidian Clipper browser extension. It enables seamless saving of web page highlights directly into Obsidian using customizable templates, similar in functionality to Readwise, but for the browser.

Intrigued by how this extension operates within the typically restricted browser environment (a necessary security measure), I delved into its open-source code.

My investigation revealed a surprisingly versatile range of interactions between Obsidian and the browser, which I'm excited to share with you in this post. The core mechanism involves leveraging the Obsidian URI protocol to transfer data from various sources. This is the basic structure:

obsidian://new?file=PATH/FILENAME&clipboard
Enter fullscreen mode Exit fullscreen mode

Understanding Obsidian URI Parameters

Here's a breakdown of the essential parameters you can use:

  • file: Specifies the path and filename within your vault. (Required for creating new notes)
  • clipboard: A flag indicating that the content should be pulled from your system clipboard.
  • vault: (Optional) Specifies a particular vault name.
  • append: Adds the content to the end of an existing note.
  • prepend: Adds the content to the beginning of an existing note.
  • silent: Opens the note without bringing the Obsidian window to the foreground.

Types of Obsidian URI Actions

You can perform several actions using Obsidian URIs:

  1. Create a New Note:

    obsidian://new?file=folder/note-name&clipboard
    
  2. Interact with Your Daily Note:

    obsidian://daily?clipboard
    
  3. Append to an Existing Note:

    obsidian://new?file=folder/note-name&clipboard&append=true
    
  4. Prepend to an Existing Note:

    obsidian://new?file=folder/note-name&clipboard&prepend=true
    

Practical Examples: Terminal Commands (macOS)

Let's explore some practical use cases using macOS terminal commands:

  1. Creating a Basic Note:

    # Copy the desired text to your clipboard
    echo "Note content" | pbcopy
    
    # Create the note in Obsidian
    open "obsidian://new?file=Test/note&clipboard"
    
  2. Creating a Note with Frontmatter:

    # Copy text including frontmatter to your clipboard
    echo '---
    title: "Test Note"
    tags: [test]
    ---
    Content here' | pbcopy
    
    # Create the note with frontmatter
    open "obsidian://new?file=Test/note&clipboard"
    
  3. Appending to Your Daily Note:

    # Copy the text you want to append
    echo "New daily entry" | pbcopy
    
    # Append the text to your daily note
    open "obsidian://daily?clipboard&append=true"
    
  4. Creating a Note in a Specific Vault:

    # Copy the text for the note
    echo "Note in specific vault" | pbcopy
    
    # Create the note in the specified vault
    open "obsidian://new?file=Test/note&vault=VaultName&clipboard"
    

Prerequisites

To use these methods effectively, ensure you have:

  • Obsidian version 1.7.2 or newer
  • An active Obsidian instance running
  • Proper URI encoding for any special characters in paths or filenames

>> Read more in my Blog Post

Top comments (0)