Skip to content

Support OSC 52 for clipboard operations over SSH #20974

Description

@kae-builds

Summary

When using Claude Code over SSH, the "c" key copy feature doesn't work on the local machine because it uses local clipboard commands (pbcopy/xclip) instead of OSC 52 escape sequences.

Problem

  1. SSH into a remote server running Claude Code
  2. Press "c" to copy code/output
  3. Cannot paste on the local machine with Cmd+V/Ctrl+V

The copied content stays on the remote server's clipboard, not the local machine where the user actually wants to paste.

Proposed Solution

Add an option to use OSC 52 escape sequences for clipboard operations. OSC 52 is widely supported by modern terminal emulators (Ghostty, iTerm2, Alacritty, WezTerm, kitty, foot, etc.) and works seamlessly over SSH, including through nested tmux sessions.

Example implementation:

printf "\e]52;c;%s\a" "$(echo "text to copy" | base64)"

This could be:

  • A configuration option (e.g., clipboard: "osc52")
  • Auto-detected when running over SSH ($SSH_TTY is set)

Environment

  • Terminal: Ghostty (OSC 52 supported)
  • tmux with set-clipboard on and allow-passthrough on
  • SSH connection to remote server

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions