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 and native Windows support via PowerShell
Installation
Homebrew (macOS / Linux)
Supports macOS (Apple Silicon) and Linux (x86_64). Intel Mac users can install via Cargo or Nix instead.
Windows
Download the pre-built binary from the latest GitHub Release:
mdpaste-windows-x86_64.exe
Place it somewhere on your PATH (e.g. C:\Users\<you>\bin\) and rename it to mdpaste.exe.
Alternatively, install via Cargo (requires Rust toolchain):
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
Or build from source:
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
| Platform | Default path |
|---|---|
| macOS / Linux | ~/.config/mdpaste/config.toml (respects XDG_CONFIG_HOME) |
| Windows | %APPDATA%\mdpaste\config.toml |
= "local" # default backend
[]
= "..."
= "https://..." # optional, defaults to https://<account_id>.r2.cloudflarestorage.com
[]
# WSL2 only: 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/
Windows Notes
On native Windows, mdpaste uses PowerShell (System.Windows.Forms) to access the clipboard. Both Windows PowerShell (powershell.exe) and PowerShell Core (pwsh.exe) are supported.
PowerShell resolution order:
pwsh.exein PATH (PowerShell Core 7+, preferred)powershell.exein PATH (Windows PowerShell 5.1, always present)- Well-known installation paths (
%ProgramFiles%\PowerShell\,%WINDIR%\System32\...)
No additional configuration is required — PowerShell ships with every modern Windows installation.
Platform Support
| Platform | Image | FileDrop |
|---|---|---|
| macOS | ✅ | ✅ |
| Linux | ✅ | ✅ |
| WSL2 | ✅ | ✅ |
| Windows | ✅ | ✅ |
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.