Skip to content

feat: replace X11 clipboard with OSC 52 for better remote terminal support#182

Open
guox18 wants to merge 2 commits into
PaulJuliusMartinez:mainfrom
guox18:main
Open

feat: replace X11 clipboard with OSC 52 for better remote terminal support#182
guox18 wants to merge 2 commits into
PaulJuliusMartinez:mainfrom
guox18:main

Conversation

@guox18
Copy link
Copy Markdown

@guox18 guox18 commented Jan 13, 2026

Summary

This PR replaces the X11-based clipboard implementation with OSC 52 escape sequences.

Motivation

When using jless over SSH without X11 forwarding, the clipboard functionality fails with:

Unable to access clipboard: XCB connection error: ClosedParseErr

OSC 52 is a terminal escape sequence that allows copying to the local clipboard through the terminal emulator, without requiring X11. It's supported by most modern terminals including:

  • iTerm2
  • kitty
  • Alacritty
  • Windows Terminal
  • tmux (with set -g set-clipboard on)

Changes

  • Remove clipboard crate dependency (X11-based)
  • Add base64 crate for encoding
  • Implement OSC 52 escape sequence for clipboard operations
  • The y commands now work in SSH sessions without X11 forwarding

Testing

Tested on remote Linux server via SSH, clipboard copy works correctly with iTerm2.

guox18 added 2 commits January 13, 2026 07:01
…pport

- Remove clipboard crate dependency (X11-based)
- Add base64 crate for encoding
- Implement OSC 52 escape sequence for clipboard operations
- Works in SSH sessions without X11 forwarding
@thomassa
Copy link
Copy Markdown

thomassa commented Jan 27, 2026

The change in this branch looks as if it will remove the ability to copy to the clipboard, for people using X11 and a terminal emulator that does not support OSC 52.

For example, according to the tmux wiki:

  • Non-default configuration is required for xterm and Kitty to support OSC 52.
  • "rxvt-unicode does not support OSC 52 natively. There is an unofficial Perl extension here."
  • "VTE terminals (GNOME terminal, XFCE terminal, Terminator) do not support the OSC 52 escape sequence."
    • I see that this is due to concerns about the security implications of allowing a remote server to read/change the contents of the local clipboard: there is a vte issue ticket with discussion.

Would it be practical to make jless use whichever is available, trying the pre-existing mechanism (from the clipboard crate) and falling back to OSC 52 on failure?

See also the approach taken in #121.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants