PJFP.com

Pursuit of Joy, Fulfillment, and Purpose

Tag: Terminal

  • The Official Obsidian CLI: A Comprehensive Guide

    The Obsidian CLI allows you to control the Obsidian desktop application directly from your terminal. Whether you want to script daily backups, pipe system logs into your daily notes, or develop plugins faster, the CLI bridges the gap between your shell and your knowledge base.

    ⚠️ Early Access Warning: As of February 2026, the Obsidian CLI is in Early Access. You must be running Obsidian v1.12+ and hold a Catalyst license to use these features.


    1. Prerequisites & Installation

    Before you begin, ensure you meet the requirements:

    • Obsidian Version: v1.12.x or higher (Early Access).
    • License: Catalyst License (required for early access builds).
    • State: Obsidian must be running (the CLI connects to the active app instance).

    Setup Steps

    1. Update Obsidian: Go to Help → Check for updates. Ensure you are on the latest installer (v1.11.7+) and update to the v1.12.x early access build.
    2. Enable the CLI:
      • Open Settings → General.
      • Scroll to “Command line interface” and toggle it On.
      • Follow the prompt to “Register” the CLI. This sets up the necessary PATH variables.
    3. Restart Terminal: You must restart your terminal session for the new PATH variables to take effect.
    4. Verify: Run obsidian help. If you see a command list, you are ready.

    2. Core Concepts & Syntax

    The CLI operates in two modes: Single Command (for scripting) and Interactive TUI (for exploration).

    Interactive Mode (TUI)

    Simply type obsidian and hit enter.

    • Features: Autocomplete, command history (Up/Down arrows), and reverse search (Ctrl+R).
    • Usage: Type commands without the obsidian prefix (e.g., just daily).

    Command Structure

    The general syntax for single commands is:

    obsidian <command> [parameters] [flags]

    Parameters & Flags

    • Parameters (key=value): Quote values if they contain spaces.

      Example: obsidian create name="My Note" content="Hello World"

      Multiline: Use \n for newlines.

    • Flags: Boolean switches to change behavior.
      • --silent: Suppress output/window focusing.
      • --copy: Copy the output to the system clipboard.
      • --overwrite: Force an overwrite if a file exists.

    Targeting Vaults & Files

    • Vault Selection:
      • Default: Uses the vault in your current working directory. If not in a vault, uses the active Obsidian window.
      • Explicit: obsidian vault="My Vault" daily
    • File Selection:
      • Wikilink Style: file=Recipe (Resolves just like [[Recipe]]).
      • Exact Path: path="Folder/Subfolder/Note.md" (Relative to vault root).

    3. Essential Workflows

    Daily Notes Management

    The CLI excels at quick capture and logging without breaking your flow.

    Open Today’s Note:

    obsidian daily

    Quick Capture (Append):
    Adds text to the end of the note without opening the window.

    obsidian daily:append content="- [ ] Call Client regarding Project X" silent

    File Operations

    Create a Note:

    obsidian create name="Project Alpha" content="# Goals\n1. Launch"

    Search & Copy:
    Finds notes containing “TODO” and copies the list to your clipboard.

    obsidian search query="TODO" --copy

    Version Control

    Diff Versions:

    # Compare current file to previous version
    obsidian diff file=Recipe from=1

    4. Automation & Scripting Patterns

    These patterns are ideal for shell scripts (.sh) or launchers like Alfred/Raycast.

    Pattern A: The “Inbox” Scraper

    Create a system-wide hotkey that runs this script to capture ideas instantly:

    # Appends to daily note with a timestamp
    timestamp=$(date +%H:%M)
    obsidian daily:append content="- $timestamp: $1" silent

    Pattern B: Automated Reporting

    Generate a file based on system data.

    # Create a note with directory listing
    ls -la | obsidian create name="System Log" --stdin

    5. Troubleshooting by OS

    Windows

    Windows requires a specialized redirector because Obsidian is a GUI app.

    Fix: You may need the Obsidian.com file (available via the Catalyst Discord). Place this file alongside Obsidian.exe in your installation directory.

    macOS

    Registration usually handles this automatically. If it fails:

    Fix: Add the following to your ~/.zprofile or ~/.bash_profile:

    export PATH="$PATH:/Applications/Obsidian.app/Contents/MacOS"

    Linux

    Fix: If the symlink is missing, create it manually:

    sudo ln -s /path/to/Obsidian-AppImage /usr/local/bin/obsidian

    Command Reference Cheat Sheet

    Category Command Example Usage
    General open, search obsidian open file="Project A"
    Daily daily, daily:append obsidian daily:prepend content="Urgent!"
    Files create, move obsidian create name="Log" overwrite
    Reading read, outline obsidian read file=Recipe

    Note: Commands and syntax are subject to change during Early Access. Always rely on obsidian help within your specific build.