# CLI — Quick Start

# CLI — Quick Start

## Install

```bash
npm install -g mdfy-cli
```

After install, the `mdfy` command is available globally.

## Publish

```bash
# Publish a file
mdfy publish README.md
# → https://mdfy.cc/d/abc123  (copied to clipboard)

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

# Publish clipboard
pbpaste | mdfy publish
```

## Pipe Anything

```bash
# AI output
claude "explain React hooks" | mdfy publish

# Git log
git log --oneline -20 | mdfy publish

# System info
system_profiler SPHardwareDataType | mdfy publish

# Man pages
man grep | mdfy publish

# Command output
curl -s https://api.example.com/status | mdfy publish
```

## Read Documents

```bash
# Read by ID
mdfy read abc123

# Read by URL
mdfy read https://mdfy.cc/d/abc123

# Output: color-coded headings, bold, code blocks, lists
```

## Manage Documents

```bash
# List your documents
mdfy list

# Update a published document
mdfy update abc123 updated-file.md

# Download to file
mdfy pull abc123 -o meeting-notes.md

# Delete
mdfy delete abc123

# Open in browser
mdfy open abc123
```

## Capture

```bash
# Auto-detect: tmux pane if in tmux, clipboard otherwise
mdfy capture

# Explicit sources
mdfy capture tmux        # Current tmux pane
mdfy capture clipboard   # System clipboard
```

AI conversations (Claude Code, ChatGPT CLI, Ollama) are auto-detected and formatted with User/Assistant roles.

## Authentication

```bash
mdfy login      # Opens browser for OAuth
mdfy whoami     # Show current user
mdfy logout     # Clear credentials
```

Credentials: `~/.mdfy/config.json`
Edit tokens: `~/.mdfy/tokens.json`

## tmux Integration

Add to `~/.tmux.conf`:

```bash
bind-key M run-shell "tmux capture-pane -p -S -1000 | mdfy publish"
```

Press `prefix + M` to publish the current pane.

## Shell Aliases

```bash
# Add to ~/.zshrc or ~/.bashrc
alias mp="mdfy publish"
alias mpc="pbpaste | mdfy publish"
```

## Short Aliases

| Short | Full |
|-------|------|
| `mdfy p` | `mdfy publish` |
| `mdfy up` | `mdfy update` |
| `mdfy ls` | `mdfy list` |
| `mdfy rm` | `mdfy delete` |
| `mdfy cat` | `mdfy read` |
| `mdfy c` | `mdfy capture` |