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