---
title: "Append to a Markdown note from Terminal or a script"
author: Pedro Thomaz
source: https://coffeetext.app/blog/append-to-markdown-note-terminal
---

# Append to a Markdown note from Terminal or a script

> Checked November 2026 on macOS 26, and against [Obsidian's URI help](https://obsidian.md/help/uri). I make Coffee, so weigh what I say about it. Coffee isn't affiliated with Obsidian.

A note you add to from outside is one of the most useful things plain files allow. A build script logs each release. A cron job writes the day's weather into your journal. A keystroke files a thought into an inbox without opening anything. Because the note is a `.md` file, the simplest version needs nothing but the shell.

## The one-liner: `>>`

From Terminal, two greater-than signs add to the end of a file:

```
echo "- Called Ana about the invoice" >> ~/Notes/Log.md
```

One `>` replaces the whole file, so it's worth typing slowly the first few times. `>>` creates the file if it isn't there, which is handy for a new log and annoying after a typo in the name.

Two things to watch:

- **A missing final newline.** If the file doesn't end with a line break, your text joins the last line. `echo` adds a newline after what it writes, but not before it.
- **The date.** `$(date +%F)` puts today's date, year first, into the line: `echo "- $(date +%F) Deployed" >> Log.md`.

This works with any editor, since the note is only a file. If the note is open in an app that doesn't notice outside changes, though, that app may save over your line. Coffee notices when a file changes outside it and shows what changed, so the line can be kept or undone.

## Under a heading, not at the end

The end of the file isn't always the right place. A daily note might have `## Ideas` in the middle and `## Notes` below it, and an idea belongs under Ideas.

Doing that with `sed` or `awk` is possible but fiddly, and easy to get wrong when the heading is missing. Here an app's own command is better, because it knows what a Markdown heading is.

## Coffee's `coffee` command

On the Mac, Coffee has a `coffee` command for Terminal. Set it up once: Settings › AI, plugins and export, click Copy command next to Terminal command, paste the line into Terminal and press Return. It asks for your Mac's password.

Then:

```
coffee append Log "Called Ana about the invoice"
coffee append --today --heading Ideas "a podcast about bees"
coffee append --prepend Reading "Started The Overstory"
```

`coffee append` adds text at the end of a note by default, at the start with `--prepend`, or under a heading with `--heading`. `--today` stands in for a title and means today's daily note. A few neighbours are handy in scripts:

- `coffee add` adds a line to `Inbox.md`, and reads stdin, as in `echo "call Ana" | coffee add`.
- `coffee new` makes a note with an optional title and text, and also reads stdin.
- `coffee today` opens today's note.
- `coffee path` prints the notes folder and `coffee list` every note's path, for scripts that want the files themselves.

`coffee help` lists the rest, and [Coffee's help on the command](https://coffeetext.app/help/terminal) has examples.

## From another app: a link

Apps that can open a link, such as a launcher, a calendar event or Shortcuts, can add to a note through a URL scheme.

In Coffee, on the Mac:

```
open "coffee://append?title=Log&text=Called%20Ana"
```

adds the text at the end of Log and opens it, so you see what came in. `path=` works in place of `title=`, and `today=1` adds to today's note. Add `heading=Ideas` to put the text at the end of what's under that heading; a note without the heading gets it at the end. `prepend=1` puts the text at the start of the note, or just under the heading. `coffee://inbox?text=...` adds a line to the Inbox without opening anything.

A link only ever adds and opens notes. None replaces or deletes anything, since a link can come from any web page. Links also follow x-callback-url, so an app like Shortcuts or Drafts gets the note's path back when Coffee is done. [Coffee's help on links](https://coffeetext.app/help/url-scheme) lists every form.

Obsidian does the same through `obsidian://new` with `append=true`, and a `heading` parameter to put the content under a heading, according to [its URI help](https://obsidian.md/help/uri).

Spaces become `%20` in a link. That's the main reason to prefer the `coffee` command in Terminal, or the [Shortcuts actions](https://coffeetext.app/blog/apple-shortcuts-siri-markdown-notes-mac), where you type text as it is.

## Ideas to copy

- **A release log.** At the end of a deploy script: `coffee append Releases "$(date +%F) v$VERSION deployed"`.
- **A reading list from the clipboard.** `pbpaste | coffee add` drops the copied link into your Inbox.
- **A daily summary.** A scheduled job that appends the day's calendar or weather under a heading in today's note.
- **From an AI app.** With Coffee's MCP server turned on, connected AI apps can add under a heading the same way, as in [connecting notes to AI over MCP](https://coffeetext.app/blog/connect-notes-to-ai-mcp).

## Questions

### How do I append a line to a Markdown file in Terminal?

`echo "your text" >> file.md` adds it to the end. Two `>` add; one `>` replaces the file, so check before pressing Return.

### Can I add text under a specific heading?

Not easily with plain shell tools. Coffee's `coffee append --heading Ideas "text"` does it, as does `heading=` in a `coffee://append` link. Obsidian's `obsidian://new` takes a `heading` parameter with `append`.

### Can a coffee:// link delete or overwrite a note?

No. Links only add to and open notes, because a link can come from any web page.

### Does coffee append open Coffee?

Yes. It hands the text to Coffee as a `coffee://append` link, so Coffee adds it and opens the note, and you see what came in. To add a line without opening anything, use `coffee add`, which goes to the Inbox.

The `coffee` command and `coffee://` links are in Coffee on the Mac, on macOS 15 or later. It's free for 14 days without a card, then €3 a month, €29 a year, or €79 once with two years of updates.

---

Written by Pedro Thomaz, who makes Coffee, a Markdown editor for the Mac on macOS 15 or later, and for iPhone and iPad. It's free for 14 days with no card or account, then €3 a month, €29 a year, or €79 once with two years of updates. More at https://coffeetext.app/llms-full.txt
