Make Obsidian a default app for Markdown files on macOS

Hi and thanks for tha bdvg. Do you mind pasting the code here so that we dont have to download anything? Thanks so much.
The thing i posted above previously was actually targeted to the user pseudmonia. Sorry about that. But thanks for replying. Cheers

Great configuration and Guide!

Was helpful to learn a bit of Automator.

Just wanted to know if script could be edited so that a new tab with the note is opened and it does not overcome(close) whatever note is currently open?

Once again, really appreciate the good work

I wish that were possible, but unfortunately it seems not. The script sends the operating system a request to open a link like obsidian://open?path=%2FUsers%2Faadhil%2FObsidian-vault%2FTemp%2FREADME.md and I’m not aware of a form of this that tells Obsidian to use a new tab.

Just wanted to say that this works so well, even two years after the fact, and that the explanation is really unusually clear. Thank you.

1 Like

This was super easy to set up and works perfectly. Thanks for sharing!

I just found this. Super handy! It solves a challenge I was having with using Hookmark to link to Obsidian files from other apps. With this approach, I can move the file to different folders and the hookmark link will still work, and open directly in obsidian when clicked. Thank you so much for sharing and with such detailed, easy to follow instructions!

Thank you very much! It worked perfectly :white_check_mark:

This is great - thank you! The steps are very clear.

Is it possible to implement this on IOS?

I just downloaded your script, created the app, but I’m still getting this type of error:
SCR-20241223-jxtv
SCR-20241223-kbjg

This is my vault:
/Users/dannywyatt/My Files/Obsidian/Tiago

I’m trying to open a file:
/Users/dannywyatt/My Files/Obsidian/Tiago/Wavebix/About Wavebix.md

Here’s my Automator, which seems to follow your instructions:

Finder is clearly seeing it as an application:

image

Am I missing a step or something else?
Thank you!

Inspired by this post, here is a version to open the any markdown file with Obsidian, by using hard links. The idea is to create a hard link in the vault to this file if the file is outside of the vault, and open it within the vault.

#!/bin/zsh

FILE="$1"
VAULT_DIR="$HOME/obsidian"  # Your vault path
HARDLINK_DIR="$VAULT_DIR/hardlinks"

[[ ! -f "$FILE" ]] && exit 1

# Get absolute path
ABS_FILE=$(realpath "$FILE")

# Check if file is already in the vault
if [[ "$ABS_FILE" == "$VAULT_DIR"/* ]]; then
    # Already in vault, open directly
    open "obsidian://open?path=$(python3 -c "import urllib.parse; print(urllib.parse.quote('$ABS_FILE'))")"
    exit 0
fi

# Not in vault, need hardlink
mkdir -p "$HARDLINK_DIR"

# Check for existing hardlink
TARGET=$(find "$HARDLINK_DIR" -samefile "$ABS_FILE" -print -quit 2>/dev/null)

if [[ -z "$TARGET" ]]; then
    # Create new hardlink
    BASENAME=$(basename "$ABS_FILE")
    TARGET="$HARDLINK_DIR/$BASENAME"
    
    # Handle name collisions
    COUNTER=1
    while [[ -f "$TARGET" ]]; do
        if [[ "$BASENAME" =~ \. ]]; then
            TARGET="$HARDLINK_DIR/${BASENAME%.*}_${COUNTER}.${BASENAME##*.}"
        else
            TARGET="$HARDLINK_DIR/${BASENAME}_${COUNTER}"
        fi
        ((COUNTER++))
    done
    
    ln "$ABS_FILE" "$TARGET" 2>/dev/null || exit 1
fi

# Open the hardlink
open "obsidian://open?path=$(python3 -c "import urllib.parse; print(urllib.parse.quote('$TARGET'))")"