c2f - Clipboard to file
Simple CLI tool to write clipboard contents to a file with content format detection.
Overview
c2f is a lightweight cross-platform command-line utility that saves or appends your clipboard contents to a file. It can automatically detect content types and add an appropriate file extension.
Installation
Homebrew (Recommended)
Cargo
From Source
Requires Rust 1.60+
Pre-built Binaries
Download the latest release from the releases page.
Usage
# write clipboard with auto-detected extension
# creates clipboard.json / clipboard.py / clipboard.md / etc.
# write clipboard to specific file
# append to file
# quiet mode (no output)
# override content detection
Options
-a, --append- Append to file instead of overwriting-q, --quiet- Suppress all output-e, --append-ext- Add detected extension to specified filename--detect=<bool>- Override content detection (true/false)-h, --help- Print help-V, --version- Print version
Configuration
c2f supports a configuration file at ~/.config/c2f/config.toml:
= false # Ask for confirmation before writing (default: false)
= false # Suppress all output (default: false)
= true # Enable content type detection (default: true)
Command-line flags override config file settings.
Examples
Basic Usage
# copy JSON and save with autodetected extension
|
# copy Python and save
|
# copy MD and save
|
Specific Filename
# save to specific file
# append to existing file
# quiet mode (no output)
Detection Control
# disable detection (always use .txt)
# force detection even if disabled in config
# append detected extension to specified filename
|
More Examples
# quietly append JSON to log file with explicit detection
|
# save code snippet with auto-extension in quiet mode
|
# override config to force detection and append extension
# copy SQL query and append to daily log
# copy code from browser/IDE, then:
# append API responses to a file
# note-taking: save formatted content with proper extensions
Supported Formats
c2f can automatically detect and assign appropriate extensions for:
Data Formats: JSON (.json), XML (.xml), YAML (.yaml), TOML (.toml), CSV (.csv), SQL (.sql)
Programming Languages:
- Rust (
.rs), Python (.py), JavaScript (.js), TypeScript (.ts) - Go (
.go), Java (.java), C# (.cs), C++ (.cpp), C (.c) - Shell (
.sh), PowerShell (.ps1), Ruby (.rb), PHP (.php) - Swift (
.swift), Kotlin (.kt)
Markup & Style: HTML (.html), Markdown (.md), LaTeX (.tex), CSS (.css), SCSS (.scss)
Config Files: Dockerfile, .gitignore, Makefile, .env, INI (.ini)
Images: PNG images from clipboard
Fallback: Plain text (.txt) for unrecognized content
Platform Support
c2f is cross-platform:
- macOS
- Linux
- Windows
License
MIT License - see LICENSE for details.
Copyright 2025 balintb