1 unstable release
Uses new Rust 2024
| 0.1.0 | Feb 25, 2026 |
|---|
#66 in #clipboard
33KB
859 lines
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 75000raw bytes. - Exceeding the limit fails with exit code
4unless--truncateis 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:
- inspect pane
allow-passthrough - enable it temporarily if currently off
- 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 successfully2: usage / argument error3: input read error4: size limit exceeded5: output device unavailable (for example/dev/ttymissing)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.