mdpaste
A CLI tool that reads an image from the clipboard, saves it as a WebP file, and outputs a Markdown image link.
Features
- Reads images and file drops from the clipboard
- Saves images in WebP format
- Supports three storage backends:
- Local: saves to a local directory (default:
images/) - R2: uploads to Cloudflare R2 and returns a public URL
- NodeBB: uploads to a NodeBB forum via the post upload API
- Local: saves to a local directory (default:
- Backend selection: CLI flag > project config > global config > local (fallback)
- WSL2 support with configurable executable path for PowerShell
Installation
Homebrew (macOS / Linux)
Supports macOS (Apple Silicon) and Linux (x86_64). Intel Mac users can install via Cargo or Nix instead.
Nix / Home Manager (recommended)
Add to your Home Manager configuration:
inputs.mdpaste.url = "github:daaa1k/mdpaste";
# in your Home Manager module:
imports = [ inputs.mdpaste.homeManagerModules.default ];
programs.mdpaste = {
enable = true;
# Optional: use the pre-built binary from GitHub Releases (no Rust compilation)
# package = inputs.mdpaste.packages.${pkgs.system}.mdpaste-bin;
settings = {
backend = "r2";
r2.account_id = "your-account-id";
# R2 credentials via R2_ACCESS_KEY_ID / R2_SECRET_ACCESS_KEY env vars
};
};
programs.mdpaste.settings is written to $XDG_CONFIG_HOME/mdpaste/config.toml automatically.
Cargo
Usage
Output example:

Configuration
Project config (.mdpaste.toml)
Place this file in your project root (or any ancestor directory). Searched upward from the current directory.
= "r2" # "local", "r2", or "nodebb" (optional, overrides global)
[]
= "images" # directory for local backend (default: "images")
[]
= "my-bucket"
= "https://assets.example.com"
= "images/" # optional key prefix
[]
= "https://forum.example.com"
Global config (~/.config/mdpaste/config.toml)
Stores machine-level defaults. Respects XDG_CONFIG_HOME.
= "local" # default backend
[]
= "..."
= "https://..." # optional, defaults to https://<account_id>.r2.cloudflarestorage.com
[]
# Optional: specify absolute path when PowerShell is not in PATH
# (e.g., when appendWindowsPath = false in /etc/wsl.conf)
= "/mnt/c/Program Files/PowerShell/7/pwsh.exe"
R2 credentials
R2 access credentials are read from environment variables:
NodeBB credentials
NodeBB login credentials are read from environment variables:
WSL2 Notes
On WSL2, mdpaste uses PowerShell to access the Windows clipboard. If PowerShell is not in PATH (e.g., appendWindowsPath = false in /etc/wsl.conf), specify its absolute path in the [wsl] section of the global config.
PowerShell resolution order:
powershell_pathfrom[wsl]configpowershell.exe/pwsh.exein PATH- Well-known paths under
/mnt/c/
Platform Support
| Platform | Image | FileDrop |
|---|---|---|
| macOS | ✅ | ✅ |
| Linux | ✅ | ✅ |
| WSL2 | ✅ | ✅ |
macOS: pngpaste
On macOS, pngpaste is recommended for reading clipboard images (screenshots, "Copy Image"):
Without pngpaste, mdpaste falls back to AppleScript, which handles PNG and TIFF clipboard data.
Files copied in Finder (FileDrop) work without pngpaste.