/copy intermittently fails inside tmux — should use DCS passthrough

Resolved 💬 3 comments Opened Mar 25, 2026 by ivansich-ant Closed May 4, 2026

Symptom

/copy reports success (Copied to clipboard (N characters)) but the content doesn't reach the system clipboard. Intermittent — sometimes works, sometimes doesn't, in the same session.

Environment

  • Claude Code running inside tmux (over SSH to a remote host)
  • tmux set-clipboard on, allow-passthrough on
  • Outer terminal: Ghostty (OSC 52 confirmed working via direct printf '\e]52;c;...\a' from a shell pane)

Root cause

/copy emits raw OSC 52 and relies on tmux's set-clipboard on to intercept and re-forward to the outer terminal. That interception is unreliable when the emitting app is in alt-screen mode (which Claude Code is). tmux sometimes catches the sequence, sometimes doesn't.

The reliable path inside tmux is the DCS passthrough wrapper:

\ePtmux;<OSC-52-with-ESC-doubled>\e\\

This bypasses tmux's interception and reaches the outer terminal directly (requires allow-passthrough on, which most tmux users already have).

Proposed fix

When $TMUX is set, wrap the OSC 52 sequence in DCS passthrough:

osc52=$(printf '\033]52;c;%s\033\\' "$encoded")
if [[ -n "${TMUX:-}" ]]; then
    printf '\033Ptmux;%s\033\\' "${osc52//$'\033'/$'\033\033'}"
else
    printf '%s' "$osc52"
fi

Workaround

set-clipboard on still populates tmux's internal buffer even when the outer forward fails. Grab it and re-send via passthrough:

tmux save-buffer - | <your-osc52-passthrough-script> -

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗