# 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
```bash
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
```bash
sshclip [OPTIONS] [FILE|-]
sshclip doctor
```
Examples:
```bash
sshclip ~/.kube/config
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.