sshclip 0.1.0

Copy remote file or stdin content into your local clipboard over SSH via OSC 52 (with tmux support)
Documentation
  • Coverage
  • 0%
    0 out of 48 items documented0 out of 16 items with examples
  • Size
  • Source code size: 33.57 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.48 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 14s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • chris-alexiuk

sshclip

sshclip copies file or stdin content from a remote shell into the local workstation clipboard by emitting an OSC 52 escape sequence.

It is designed for SSH workflows and supports tmux passthrough wrapping.

Install

cargo install sshclip

Why this works

OSC 52 is interpreted by the local terminal emulator. Over SSH, bytes printed by the remote process are still rendered locally, so clipboard write requests can be sent without X11 forwarding or a local daemon.

Usage

sshclip [OPTIONS] [FILE|-]
sshclip doctor

Examples:

sshclip ~/.kube/config
kubectl get secret my-secret -o yaml | sshclip
sshclip --selection primary ~/.ssh/id_rsa.pub
sshclip --max-bytes 200000 --truncate big.txt
sshclip doctor

Defaults and safety

  • Output target defaults to /dev/tty (not stdout), so escape sequences do not pollute pipelines.
  • Default size cap is --max-bytes 75000 raw bytes.
  • Exceeding the limit fails with exit code 4 unless --truncate is used.
  • Multiple input paths require --concat.

tmux notes

When inside tmux, sshclip wraps OSC 52 in tmux DCS passthrough framing.

By default, sshclip attempts to:

  1. inspect pane allow-passthrough
  2. enable it temporarily if currently off
  3. restore previous value after emit

Disable mutation with --no-tmux-fix.

If tmux warnings must be fatal, use --strict-tmux.

Exit codes

  • 0: sequence emitted successfully
  • 2: usage / argument error
  • 3: input read error
  • 4: size limit exceeded
  • 5: output device unavailable (for example /dev/tty missing)
  • 6: tmux integration failure in strict mode

Security note

Any program that can print to your terminal can attempt OSC 52 clipboard writes. Treat untrusted commands accordingly.