claude-code - 💡(How to fix) Fix Image paste via Cmd+V doesn't work on Linux (macOS-only guard) [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#48402Fetched 2026-04-16 07:01:10
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×4

Root Cause

In cli.js, function GCK, the empty paste handler has a macOS guard:

if (W.length === 0 && w && _)

Where w = (k1() === "macos"). On Linux, k1() returns "linux", so w is false, and the clipboard image check never runs. An empty paste (which is what terminals send when the clipboard contains an image) is silently ignored.

Code Example

if (W.length === 0 && w && _)

---

// Before:
if (W.length === 0 && w && _)

// After:
if (W.length === 0 && _)
RAW_BUFFERClick to expand / collapse

Bug Description

When pasting images via Cmd+V (terminal paste) over SSH into Claude Code running on Linux, the clipboard image check is skipped. The paste handler only checks for clipboard images on macOS.

Root Cause

In cli.js, function GCK, the empty paste handler has a macOS guard:

if (W.length === 0 && w && _)

Where w = (k1() === "macos"). On Linux, k1() returns "linux", so w is false, and the clipboard image check never runs. An empty paste (which is what terminals send when the clipboard contains an image) is silently ignored.

Environment

  • Local: macOS (Ghostty terminal, also tested Termius)
  • Remote: Ubuntu 24.04 on Hetzner VPS, Claude Code v2.1.107
  • Connection: SSH with cc-clip (xclip shim + SSH reverse tunnel for clipboard bridging)

What works

  • Ctrl+V works — the chat:imagePaste keybinding correctly calls xclip and reads the image via the cc-clip shim
  • cc-clip paste works — the full pipeline (daemon → tunnel → shim → image file) is functional
  • The xclip shim correctly returns image/png for TARGETS and the full image data

What doesn't work

  • Cmd+V (terminal paste action) — sends an empty bracketed paste, Claude Code checks w (macOS guard), finds it's Linux, does nothing

Suggested Fix

Remove the macOS guard from the empty paste check, or extend it to Linux:

// Before:
if (W.length === 0 && w && _)

// After:
if (W.length === 0 && _)

This would allow the cc-clip xclip shim approach to work seamlessly with Cmd+V paste over SSH, which is a very common setup (Hetzner VPS + SSH + Claude Code).

Related Issues

  • #5277 (Image paste over SSH)
  • #14635 (xclip clipboard detection)
  • #25935 (TARGETS grep pattern)

extent analysis

TL;DR

Remove the macOS guard from the empty paste check in cli.js to enable clipboard image checks on Linux.

Guidance

  • Identify the GCK function in cli.js and locate the macOS guard condition if (W.length === 0 && w && _).
  • Modify the condition to remove the macOS check, allowing the clipboard image check to run on Linux: if (W.length === 0 && _).
  • Verify that the change enables Cmd+V paste to work correctly over SSH on Linux by testing with an image in the clipboard.
  • Review related issues (#5277, #14635, #25935) for additional context on image paste and xclip clipboard detection.

Example

// Modified GCK function in cli.js
if (W.length === 0 && _) {
  // clipboard image check code here
}

Notes

This fix assumes that the xclip shim and cc-clip setup are correctly configured and functional, as indicated in the issue description.

Recommendation

Apply the suggested fix by removing the macOS guard from the empty paste check, as it will enable the desired functionality on Linux without introducing known issues.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING