Skip to main content

jupyterlab_terminal_clipboard_extension

GitHub Actions npm version PyPI version Total PyPI downloads JupyterLab 4 Brought To You By KOLOMOLO Donate PayPal

Terminal programs running inside JupyterLab normally cannot copy anything to your clipboard. Tools like password managers, vim, tmux, and other TUI applications that rely on xclip or xsel fail silently because there is no X11 display in a browser-based terminal. This extension fixes that - when a terminal program copies something, it lands in your browser clipboard so you can paste it anywhere.

Features

  • OSC 52 clipboard interception - captures clipboard escape sequences from terminal output
  • Auto-installing shims - deploys xclip, xsel, wl-copy replacements to ~/.local/bin/ on startup when real tools are not functional (no display server)
  • Non-destructive install - only installs shims when the real tools cannot work, and never overwrites a clipboard tool it did not create

Installation

Requires JupyterLab 4.6.0 or higher.

pip install jupyterlab_terminal_clipboard_extension

Ensure ~/.local/bin is in your PATH for the shims to work:

export PATH="$HOME/.local/bin:$PATH"

Inside tmux, a copy made by a program in a pane (xclip, xsel, wl-copy or raw OSC 52) reaches the browser only when set -g set-clipboard on is in ~/.tmux.conf; with the tmux default (external) tmux discards it and the shim still exits 0.

Uninstall

To remove the extension, execute:

pip uninstall jupyterlab_terminal_clipboard_extension

Technical Details

The extension has two components. The frontend plugin registers an OSC 52 parser handler on each terminal's xterm.js instance. When a terminal application writes \033]52;c;<base64>\a, the handler decodes the payload and writes it to the browser clipboard via navigator.clipboard.writeText(), falling back to document.execCommand('copy') for HTTP (non-secure) contexts. An OSC 52 sequence in the output the server resends after a page reload or reconnect is ignored.

Both of those paths need a focused document, and a terminal program emits OSC 52 whenever it likes - routinely while you are in another window. A copy that arrives unfocused is therefore held rather than attempted, and written when focus returns. One copy is held at a time, the newest wins, and a copy that waits longer than 15 seconds is discarded rather than landing on top of something you have copied elsewhere in the meantime. Every outcome is logged, so a copy is never lost silently.

The held copy is written from a focus or visibilitychange event, which Chrome accepts for a focused tab. Firefox requires a genuine user gesture for clipboard writes and refuses this one, logging the refusal - re-run the command with the tab focused to copy there.

The server plugin runs on JupyterLab startup and installs lightweight POSIX shell shims into ~/.local/bin/. These shims replace xclip, xsel, and wl-copy - the system clipboard tools that terminal programs call. Instead of talking to an X11 display, the shims base64-encode the input and emit an OSC 52 escape sequence to /dev/tty, which the frontend plugin then intercepts.

terminal app -> xclip/xsel (shim) -> OSC 52 escape sequence -> extension -> browser clipboard

Shims are only installed when the real tools cannot function (no DISPLAY or WAYLAND_DISPLAY environment variable set). If a real X11 or Wayland clipboard is available, the shims are not deployed and the original tools are preserved. An existing file in ~/.local/bin that is not one of our shims is never overwritten - the installer logs a warning and skips it, so a clipboard tool you placed there yourself stays intact.

Because OSC 52 only reaches the browser through the terminal, the shims write the escape sequence exclusively to /dev/tty. When a program calls them without a controlling terminal, they exit non-zero with a message on stderr rather than emitting the sequence to stdout, where it would corrupt the caller's output.

Contributing

If you would like to contribute to this extension, please refer to the Contributing Guide.

Metadata

Release files for jupyterlab-terminal-clipboard-extension 1.0.20

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jupyterlab-terminal-clipboard-extension 1.0.20
File Size Uploaded Provenance Actions
jupyterlab_terminal_clipboard_extension-1.0.20.tar.gz 353.5 kB Without provenance Details for jupyterlab_terminal_clipboard_extension-1.0.20.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jupyterlab-terminal-clipboard-extension 1.0.20
File Interpreter ABI Platform Actions
jupyterlab_terminal_clipboard_extension-1.0.20-py3-none-any.whl Python 3 none any Details for jupyterlab_terminal_clipboard_extension-1.0.20-py3-none-any.whl

Total release size: 396.5 kB

Release files / jupyterlab_terminal_clipboard_extension-1.0.20.tar.gz

Download URL jupyterlab_terminal_clipboard_extension-1.0.20.tar.gz
Size 353.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a6be43401ad7ee1c01c23773e130fe0383f89fc88148a13b1d929afc26d331f4
BLAKE2b-256 checksum
How to use checksums
58d71c282931ac5e25ff3749e858801b6f510147530df846db9fdafc197866b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Release files / jupyterlab_terminal_clipboard_extension-1.0.20-py3-none-any.whl

Download URL jupyterlab_terminal_clipboard_extension-1.0.20-py3-none-any.whl
Size 42.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b88ff9c57060ea3c63a14f54c45861e09ccfcf47adacd89d2ef8df7a3aeaa4ed
BLAKE2b-256 checksum
How to use checksums
2c03488d1950bd449cb33db10414d468ea7cbf1baad4bc21602cc1a53ff591ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Security for jupyterlab-terminal-clipboard-extension 1.0.20

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page