Skip to main content

Copy stdin or arguments to the system clipboard via the OSC 52 terminal escape sequence — works over SSH + tmux.

Project description

osc52

Copy stdin (or arguments) to the system clipboard via the OSC 52 terminal escape sequence. Designed to work over SSH + tmux: the escape is written to stderr, streamed back to your local terminal, and routed to your local clipboard — so ssh server "nvidia-smi | osc52" copies the remote output to your local machine, no remote clipboard tool required.

This is the Python port of the Go tool of the same name, distributed on PyPI so pip install osc52 gives you the osc52 command directly.

Install

pip install osc52

This installs an osc52 executable onto your PATH (an osc52.exe shim on Windows).

Usage

# Default: echo input to stdout AND copy to clipboard.
nvidia-smi | osc52

# Copy only, no echo.
nvidia-smi | osc52 -q

# Copy a file.
osc52 < config.yaml

# Copy a literal string.
osc52 "https://example.com/token"

How it works

stdin/argv ──▶ echo to stdout (visible) ─────────────────▶ terminal / pipe
          └─▶ base64 ─▶ ESC ] 52 ; c ; <b64> BEL ─▶ stderr ─▶ terminal
                                                              (parses OSC 52
                                                               → local clipboard)
  • Echo goes to stdout so downstream pipes stay clean of escape sequences.
  • OSC 52 goes to stderr so the terminal still parses it, but it never pollutes piped output.
  • Large payloads are split into ≤32KB base64 chunks; terminals accumulate same-selection sequences into the clipboard.

Options

Flag Meaning
-q, --quiet Do not echo input to stdout
--version Print version
-h, --help Help

Terminal support

OSC 52 is supported by Windows Terminal, iTerm2, kitty, Alacritty, WezTerm, foot, and recent GNOME Terminal. In tmux, ensure set -g set-clipboard on.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

osc52-0.1.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

osc52-0.1.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file osc52-0.1.0.tar.gz.

File metadata

  • Download URL: osc52-0.1.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for osc52-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b6a8f887f612a05a1034ea0bb14a240296929410c4f56e25922bb2200ab868e5
MD5 56ac58d06bf94a3346d637d40414a18d
BLAKE2b-256 f04aa544805426e02ddbc5d37cd9badeb5d099487a56d7b27aa9ae85fd2d880d

See more details on using hashes here.

Provenance

The following attestation bundles were made for osc52-0.1.0.tar.gz:

Publisher: release.yml on decajoin/osc52

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file osc52-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: osc52-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for osc52-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 293344ce228340490742a8babf75485529d4ec06981d6191640949d37df3138f
MD5 b1e66a63f7096af0c6d57d7656f8ff2c
BLAKE2b-256 7d44f1eb6b7a2f6dfab894e04d9c5ffd5b568a852d4bc36e7dc0dfd867d8cb40

See more details on using hashes here.

Provenance

The following attestation bundles were made for osc52-0.1.0-py3-none-any.whl:

Publisher: release.yml on decajoin/osc52

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page