Enhanced CLI Append/Prepend: Target Content to Specific Headings

Use case or problem

Currently, append and prepend commands only add content to the end/beginning of files. Users need to append to specific sections under headings (like ## Timestamp in Daily Notes).

Proposed solution

Add new parameters to append/prepend commands:

content=<text>     # (required) content to prepend

heading=<heading> # Add content under specific heading 🆕️

For example:

obsidian daily:append content="12:30 do something" heading="Timestamp"

Current workaround

  1. Place frequently-used headings at file ends (doesn’t work with multiple headings.
    )
  2. Use create override to re-write whole file.

Related FRss

CLI commands to address lines and headings - Feature requests - Obsidian Forum

Others

This might also be needed in Obsidian URL and iOS Shortcuts, etc.

3 Likes

It would be good to enable this for Obsidian URIs too. (I know that’s a separate feature, but I mention it here in case the code for appending could be shared by them.)

1 Like

Agree! :handshake:t2:

Advanced URI plugin provides many different navigation parameters: Navigation - Advanced URI Documentation - Obsidian Publish
I think it could be a nice reference.

/ parameters explanation
file Opens file
line and/or column in file , line, column Opens column in line in file (1 indexed)
offset in file , offset Sets the cursor at offset in file. Offset is the character count from the start
heading in file , heading Opens the heading in file