Skip to content
Back to skills

Cf Tools Productivity Clipboard Copy

ASecurity

Copy stdin or file contents to the system clipboard (pbcopy on macOS, xclip/wl-copy on Linux). Trigger: /cf-tools-productivity-clipboard-copy

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 11, 2026
toolsgoshellbash

Works with

  • cli

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add pauldx/claudifying --skill cf-tools-productivity-clipboard-copy --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Cf Tools Productivity Clipboard Copy?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Cf Tools Productivity Clipboard Copy
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/pauldx-cf-tools-productivity-clipboard-copy/badge)](https://www.skillsdirectory.com/skills/pauldx-cf-tools-productivity-clipboard-copy)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: cf-tools-productivity-clipboard-copy
description: "Copy stdin or file contents to the system clipboard (pbcopy on macOS, xclip/wl-copy on Linux). Trigger: /cf-tools-productivity-clipboard-copy"
trigger: /cf-tools-productivity-clipboard-copy
version: 1.0.0
---

# /cf-tools-productivity-clipboard-copy

Send text to the OS clipboard. Cross-platform wrapper around `pbcopy` (macOS), `xclip` / `xsel` (X11), and `wl-copy` (Wayland).

## Usage

```
echo "hello" | /cf-tools-productivity-clipboard-copy
/cf-tools-productivity-clipboard-copy /path/to/file.txt
/cf-tools-productivity-clipboard-copy --strip /path/to/file.txt   # trim trailing newline
```

Arguments:
1. `path` (optional) — if omitted, reads stdin
2. `--strip` (optional) — drop a single trailing newline before copying

## What You Must Do When Invoked

### Step 1 — Detect platform and clipboard tool

```bash
PLATFORM="$(uname -s)"
COPY_CMD=""

case "$PLATFORM" in
  Darwin)
    COPY_CMD="pbcopy"
    ;;
  Linux)
    if [ -n "$WAYLAND_DISPLAY" ] && command -v wl-copy >/dev/null 2>&1; then
      COPY_CMD="wl-copy"
    elif command -v xclip >/dev/null 2>&1; then
      COPY_CMD="xclip -selection clipboard"
    elif command -v xsel >/dev/null 2>&1; then
      COPY_CMD="xsel --clipboard --input"
    else
      echo "ERROR: no clipboard tool found."
      echo "Install one: sudo apt install xclip   (or wl-clipboard on Wayland)"
      exit 2
    fi
    ;;
  *)
    echo "ERROR: unsupported platform: $PLATFORM"
    exit 2
    ;;
esac
```

### Step 2 — Read source

```bash
SRC="$1"
if [ -n "$SRC" ] && [ "$SRC" != "--strip" ]; then
  [ -f "$SRC" ] || { echo "ERROR: file not found: $SRC"; exit 1; }
  PAYLOAD="$(cat "$SRC")"
  SRC_LABEL="$SRC"
else
  PAYLOAD="$(cat)"
  SRC_LABEL="stdin"
fi

if [ "$STRIP" = "1" ]; then
  PAYLOAD="${PAYLOAD%$'\n'}"
fi
```

### Step 3 — Copy and report

```bash
printf '%s' "$PAYLOAD" | eval "$COPY_CMD"
BYTES=${#PAYLOAD}
LINES=$(printf '%s' "$PAYLOAD" | wc -l | tr -d ' ')
echo "✅ Copied to clipboard"
echo "   Source:   $SRC_LABEL"
echo "   Bytes:    $BYTES"
echo "   Lines:    $LINES"
echo "   Tool:     $COPY_CMD"
```

## Output Contract

```
## Clipboard copy
**Source:**   stdin | <abs-path>
**Bytes:**    <N>
**Lines:**    <N>
**Tool:**     pbcopy | xclip | xsel | wl-copy
**Preview:**  "<first 60 chars>…"
```

## Gotchas

- **macOS pbcopy strips trailing newlines silently**: that's normal; not a bug.
- **xclip vs xsel**: prefer xclip — wider install base. Both use `-selection clipboard` (not primary).
- **Wayland over X11**: if both `DISPLAY` and `WAYLAND_DISPLAY` are set, prefer `wl-copy` to match active session.
- **SSH sessions**: clipboard tools fail without a display server. Recommend `OSC52` escape sequences for remote shells (out of scope here).
- **Binary data**: this skill is text-only. Don't pipe images or raw bytes — use the OS file-clipboard for that.
- **Very large payloads**: macOS pbcopy has been observed to truncate >65k chars in some shells; warn if input exceeds 50k.

## Cross-Platform Notes

- **macOS**: `pbcopy` ships built-in. Paste with `pbpaste`.
- **Linux X11**: `sudo apt install xclip` or `sudo apt install xsel`.
- **Linux Wayland**: `sudo apt install wl-clipboard` (provides `wl-copy`/`wl-paste`).
- **Windows / WSL**: use `clip.exe` from inside WSL: `cat file | clip.exe`. Not auto-detected by this skill yet.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in tools →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.