CLI

Command Line Interface

Publish Markdown from the terminal. Pipe stdin, capture tmux panes, manage documents.

Installation

bash
npm install -g mdfy-cli

Requires Node.js 18+. After install, use the mdfy command.

Commands

mdfy publish <file>Publish a Markdown file or stdin to mdfy.app.
mdfy update <id> <file>Update an existing document with new content.
mdfy pull <id>Download a document's Markdown content.
mdfy delete <id>Soft-delete a document.
mdfy listList all your documents.
mdfy open <id>Open a document in the browser.
mdfy captureCapture the current tmux pane and publish.
mdfy loginAuthenticate with mdfy.app.
mdfy logoutClear stored credentials.
mdfy whoamiShow current authenticated user.

publish

Publish a file or stdin. Returns the document URL.

bash
# Publish a file
mdfy publish README.md

# Publish from stdin
echo "# Hello World" | mdfy publish

# Publish as draft
mdfy publish README.md --draft

# Publish with title
mdfy publish README.md --title "My Document"

# Publish with password
mdfy publish README.md --password "secret"

# Publish with expiration
mdfy publish README.md --expires 7d

Options

--draft, -dPublish as draft (only visible to you).
--title, -tSet document title.
--password, -pPassword-protect the document.
--expires, -eSet expiration: 1h, 1d, 7d, 30d.
--open, -oOpen in browser after publishing.

update

Update an existing document. The edit token is stored automatically from the original publish.

bash
# Update from file
mdfy update abc123 README.md

# Update from stdin
echo "# Updated" | mdfy update abc123

# Update with version note
mdfy update abc123 README.md --message "Fixed typos"

pull

Download a document's Markdown content.

bash
# Print to stdout
mdfy pull abc123

# Save to file
mdfy pull abc123 -o output.md

# Pull with password
mdfy pull abc123 --password "secret"

delete

bash
mdfy delete abc123

# Skip confirmation
mdfy delete abc123 --yes

list

bash
mdfy list

# Output:
#  ID       TITLE              UPDATED         STATUS
#  abc123   My Document        2 hours ago     published
#  def456   Draft Note         5 minutes ago   draft

open

bash
mdfy open abc123
# Opens https://mdfy.app/abc123 in your default browser

capture

Capture the current tmux pane output and publish it as a code block.

bash
# Capture current pane
mdfy capture

# Capture specific pane
mdfy capture -t %3

# Capture last N lines
mdfy capture --lines 50

Authentication

bash
# Authenticate (opens browser for OAuth)
mdfy login

# Clear stored credentials
mdfy logout

# Show current user
mdfy whoami
# user@example.com (authenticated via OAuth)

Authentication is optional. Without login, documents are created anonymously with edit tokens. Login enables mdfy list and account-based ownership.

Pipe Examples

bash
# Clipboard to mdfy
pbpaste | mdfy publish

# Command output
ls -la | mdfy publish

# Cat a file
cat report.md | mdfy publish

# Generate with AI, publish directly
claude "Write a guide to Rust" | mdfy publish

# Git diff
git diff | mdfy publish --title "Changes"

# Docker logs
docker logs my-app 2>&1 | mdfy publish

# Pipe through multiple commands
curl -s https://api.example.com/data | jq . | mdfy publish

tmux Integration

bash
# Capture current pane
tmux capture-pane -p | mdfy publish

# Capture and share with one keybinding
# Add to ~/.tmux.conf:
bind-key M run-shell "tmux capture-pane -p | mdfy publish"

# Capture specific pane
tmux capture-pane -t %3 -p | mdfy publish

# Capture full scrollback
tmux capture-pane -p -S - | mdfy publish

Shell Aliases

bash
# Add to ~/.zshrc or ~/.bashrc

# Quick publish
alias mp="mdfy publish"

# Publish clipboard
alias mpc="pbpaste | mdfy publish"

# Publish and open
alias mpo="mdfy publish --open"

# Capture tmux
alias mtx="tmux capture-pane -p | mdfy publish"

Configuration

Environment Variables

MDFY_URLBase URL for the API. Default: https://mdfy.app

Config File

Credentials are stored in ~/.mdfy/config.json after mdfy login. Edit tokens for published documents are stored in ~/.mdfy/tokens.json.

json
// ~/.mdfy/config.json
{
  "apiUrl": "https://mdfy.app",
  "email": "user@example.com",
  "token": "..."
}