展示 HN:Stash – 通过 CLI 同步 Markdown 文件与 Apple Notes
Show HN: Stash – Sync Markdown Files with Apple Notes via CLI

原始链接: https://github.com/shakedlokits/stash

## Stash:Markdown 与 Apple Notes 同步 Stash 是一款新的命令行工具,旨在无缝同步 Markdown 文件与 Apple Notes。它由一位长期 Apple Notes 用户创建,该用户对现有解决方案感到沮丧,Stash 提供了一个简单、双向的同步,而无需其他笔记应用程序的复杂性。 该工具利用 Markdown 文件中的 front-matter 来跟踪相应的 Apple Notes,使用户能够轻松地将 Markdown 内容**推送到** Notes,并将 Notes 中的更改**拉回**到 Markdown 文件中。它基于 AppleScript 构建以保证稳定性,使用 shell 脚本进行逻辑处理,并使用 Pandoc 进行格式化。 **安装非常简单:** 通过 Homebrew 使用 `brew tap shakedlokits/stash` 和 `brew install shakedlokits/stash/stash`。 Stash 旨在弥合那些喜欢使用 Markdown 进行草稿编写,但依赖 Apple Notes 以实现快速访问和便携性的用户之间的差距,从而为跨平台管理想法和笔记提供精简的工作流程。该项目是开源的,并欢迎贡献。

相关文章

原文
                                     
                                     
  ▄█████ ██████ ▄████▄ ▄█████ ██  ██ 
  ▀▀▀▄▄▄   ██   ██▄▄██ ▀▀▀▄▄▄ ██████ 
  █████▀   ██   ██  ██ █████▀ ██  ██ 
                                     
                                     

Bidirectionally sync Markdown files with Apple Notes!

brew tap shakedlokits/stash https://github.com/shakedlokits/stash
brew install shakedlokits/stash/stash

Push a markdown file to Apple Notes:

Pull changes back from Apple Notes:

That's it! The tool uses front-matter to track which Apple Note corresponds to your file.

Apple Notes has been my daily driver for years. I love its simplicity—it syncs fast, stays out of the way, and just lets me write.

I've explored the full spectrum of note-taking apps: Workflowy, Obsidian, Bear, Evernote, Notion, Google Keep, GoodNotes, and others I've since forgotten. Each promised to revolutionize how I capture thoughts. But eventually, I realized something simple: note-taking is about writing things down, not managing a complex system. I came back to Apple Notes and haven't looked back.

There's just one friction point. When I'm building things—which is most days—I live in Markdown. At work, I sync those files to Notion or Confluence with CLI tools. For personal projects, everything goes into Git. But increasingly, I find myself writing quick notes that don't belong to any project—just ideas, experiments, small discoveries—and I want them on Apple Notes where I can read them anywhere. Right now, there's no clean path from my Markdown workflow to my notes.

I went searching for CLI tools to bridge this gap. What I found was disappointing: tools either pack in too many features, making them brittle and hard to maintain, or they offer so little functionality (read-only sync) that they're effectively useless.

So I built my own.

The requirements are straightforward:

  • Run from the shell without configuration files
  • Use AppleScript for maximum compatibility and stability
  • Bidirectionally sync Markdown and Apple Notes, using front-matter to track state

Congratulations! You've written a new Markdown note, it's nice and tidy, and you've even run vale on it. Now all that remains is getting it into Apple Notes. Here's what you need to do:

  1. Run push my-cool-note.md.
  2. A new note will be created:
  3. Front-matter with a unique identifier will be added to your markdown file:
    ---
    apple_notes_id: my-new-cool-note-identifier 
    ---
    
    # My Cool Note
    ...

    NOTE: If you already have front-matter, it will be added to the existing front-matter.

Made changes to the Markdown file and now it's out of sync? Simply:

  1. Rerun push my-cool-note.md.
  2. The tool searches for the note matching your identifier (id_my-new-cool-note-identifier).
  3. It rewrites the note's content with your updated Markdown.

    NOTE: If no note was found (due to unexpected ID changes) you will be asked if you'd like to create a new note, which will overwrite your previous ID.

You've gone off for your coffee/potty/meeting break, and while skimming through your note on your phone, you realized you made a terrible mistake—which inevitably led you to rewrite half of it.

Now the panic has settled, you're back at your computer, and you're wondering: "What the hell have I done, and how can I possibly get all those changes back into my Markdown?"

Don't fret. Simply:

  1. Run pull my-cool-note.md.
  2. The tool searches for the note matching your identifier (id_my-new-cool-note-identifier).
  3. It rewrites your local Markdown file with the content from Apple Notes.

    NOTE: The front-matter is unchanged during pull operations.

  • macOS with Apple Notes
  • Pandoc for Markdown ↔ HTML conversion
  • pcregrep for frontmatter parsing (usually pre-installed on macOS, or install via brew install pcre)

The tool is built in three layers:

AppleScript forms the core, handling all communication with Apple Notes—finding existing notes, updating content, and creating or deleting notes (the latter mostly for testing).

Shell scripts contain the business logic that orchestrates these AppleScript operations, managing the sync workflow and front-matter processing.

Pandoc handles the conversion between Markdown and HTML, ensuring content is properly formatted for Apple Notes.

Bashly ties it all together, providing a clean CLI interface, shell completions, and command scaffolding.

Clone the repository and build:

git clone https://github.com/shakedlokits/stash.git
cd stash
make build
# Run all tests (requires Apple Notes access)
make test

# Run unit tests only (no Apple Notes required)
make test-unit
src/
  lib/           # Utility functions (pure and integration)
  bashly.yml     # CLI configuration
  *_command.sh   # Command implementations
test/
  cases/         # Test specs (unit, integration, e2e)
  fixtures/      # Test fixture files
  approvals/     # Approval test snapshots
dist/
  stash          # Generated CLI (via bashly)
Formula/
  stash.rb       # Homebrew formula
make release VERSION=x.y.z

This will:

  1. Update the version in src/bashly.yml
  2. Commit the change
  3. Create and push a git tag
  4. Trigger the release workflow (build, publish, update Homebrew formula)

This backlog contains both current and future development items, feel free to take some or add to it:

联系我们 contact @ memedata.com