thiagowfx's avatar

¬ just serendipity 🍀 (not just serendipity)

new script: copy

• 162 words • 1 min • updated

Previously.

I decided to add a new copy script to pancake to standardize copying command output and files to the system clipboard in both macOS and Linux.

The idea was originally inspired by Evan Hahn:

copy and pasta are simple wrappers around system clipboard managers, like pbcopy on macOS and xclip on Linux. I use these all the time.

Evan’s version is concise and elegant.

My version is more verbose, for the sake of consistency with the rest of my scripts in pancake.

Usage #

bash
# Copy from stdin
echo "BANANA42SPLIT88SUNDAE99CHERRY" | copy

# Copy a file
copy notes.txt

# Copy multiple files
copy *.md

Platform Support #

  • macOS: Uses pbcopy (built-in)
  • Linux: Auto-detects first available tool: — wl-copy (Wayland) — prioritized for modern desktops — xclip (X11) — xsel (X11)

Features #

  • Silent on success (Unix philosophy)
  • Supports stdin input
  • Supports single or multiple files
  • Multiple files are concatenated with newline separators
  • Clear error messages for missing files or dependencies