Skip to content

enderyildirim/clipflat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ClipFlat

Trimmy-style clipboard flattener for macOS. Auto-detects multi-line shell commands in your clipboard and flattens them to a single line.

Built for Intel Mac users who can't run Trimmy (ARM-only), or anyone who prefers a lightweight, zero-dependency alternative.

What it does

Copy a multi-line command from a blog post, README, or Stack Overflow:

docker run \
  --name my-app \
  -p 8080:80 \
  -v /data:/data \
  nginx:latest

ClipFlat automatically rewrites your clipboard to:

docker run --name my-app -p 8080:80 -v /data:/data nginx:latest

Paste once, run once.

Features

  • Smart detection — Scoring system identifies shell commands (pipes, &&, \ continuations, redirects, known command prefixes like git, docker, curl, etc.)
  • False positive protection — Won't touch source code, bullet lists, markdown headings, or plain text
  • Full transform pipeline:
    • Box-drawing character removal (, , , etc.)
    • Shell prompt stripping ($ and #)
    • URL fragment repair (joins URLs split across lines)
    • Path quoting (wraps paths with spaces)
    • Line flattening (joins \ continuations and remaining lines)
  • Safety limits — Skips text over 10 lines or 5000 characters
  • Self-write detection — Won't re-process its own clipboard writes
  • Auto-start — LaunchAgent starts at login, restarts on crash

Requirements

  • macOS (Intel or Apple Silicon)
  • bash (pre-installed)
  • perl (pre-installed — used for Unicode box-drawing removal)

No other dependencies. No Homebrew packages. No Xcode.

Note: While ClipFlat was built for Intel Macs where Trimmy can't run, it works on Apple Silicon too. If you want a native Swift menu-bar app with more features, check out Trimmy. If you want something simple and dependency-free, ClipFlat is for you.

Install

git clone https://github.com/enderyildirim/clipflat.git ~/dev/clipflat
bash ~/dev/clipflat/install.sh

This creates a symlink at ~/.local/bin/clipflat and registers a LaunchAgent that starts automatically at login.

Uninstall

bash ~/dev/clipflat/uninstall.sh

Usage

ClipFlat runs in the background — no interaction needed. Copy a multi-line shell command, wait ~200ms, paste it. Done.

Manual control

# Check if running
launchctl list | grep clipflat

# Stop
launchctl unload ~/Library/LaunchAgents/com.clipflat.agent.plist

# Start
launchctl load ~/Library/LaunchAgents/com.clipflat.agent.plist

# Watch activity
tail -f /tmp/clipflat.log

How it works

  1. Polls the clipboard every 150ms (lightweight, hash-based change detection)
  2. Scores the text for shell command signals:
    • Strong signals (+2): \ continuation, | pipe, &&/||, >/< redirects
    • Weak signals (+1): known command prefix, --flag, VAR=value
  3. If score >= 2 and text passes false-positive checks, runs the transform pipeline
  4. Writes the flattened result back to the clipboard

Tests

172 tests covering every function and edge case:

bash ~/dev/clipflat/test_clipflat.sh

Contributing

Issues and pull requests are welcome! If you find a false positive (text that shouldn't be flattened but is) or a false negative (command that should be flattened but isn't), please open an issue.

License

MIT

About

Trimmy-style clipboard flattener for Intel Macs — auto-detects and flattens multi-line shell commands in your clipboard

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages