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
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
Examples:
|
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.