为什么在 WSL 的 Claude Code 中无法通过 Ctrl+V 粘贴图片及解决方法
Why Ctrl+V won't paste images in Claude Code on WSL, with a fix

原始链接: https://rajveerbachkaniwala.com/blog/2026/05/24/on-the-difficulty-of-pasting-a-picture/

目前在 WSL 中运行的 Claude Code 无法直接粘贴 Windows 图像,这主要是由以下三个相互重叠的问题导致的: 1. **格式不兼容**:WSLg 会将 Windows 图像转换为 Claude Code 无法处理的晦涩 BMP 格式。 2. **剪贴板劫持**:每当 Windows 剪贴板发生变化时,WSLg 会静默地用这种损坏的 BMP 格式覆盖 Linux 剪贴板,导致手动变通方案失效。 3. **键盘拦截**:Windows Terminal 会拦截 `Ctrl+V` 用于自身操作,导致该按键指令无法传递给 Claude Code。 **解决方案:** 为绕过这些问题,作者开发了 `wsl-clip-bridge`。它包含以下部分: * **Windows 监听器**:捕获剪贴板图像并将其转换为有效的 PNG 格式。 * **Linux 桥接器**:强制将 PNG 数据写入 Linux 剪贴板,并持续重新同步以抵消 WSLg 的覆盖行为。 * **自定义快捷键**:将 Claude Code 中的粘贴命令重新映射为 `Alt+V`,以避开 Windows Terminal 对 `Ctrl+V` 的拦截。 虽然这些是属于上游的问题,理应由微软和 Claude 最终修复,但该桥接工具提供了一个可靠的变通方法。你可以在 [github.com/rajveerb/wsl-clip-bridge](https://github.com/rajveerb/wsl-clip-bridge) 获取安装脚本和源代码。

目前将图片从 Windows 粘贴到 WSL 上的 Claude Code 会失败,这主要源于三个问题:WSL 与 Windows 的 BMP 剪贴板格式不兼容、WSL 倾向于覆盖剪贴板数据,以及 Windows Terminal 拦截了 `Ctrl+V` 命令。 为了解决这个问题,开发者 Rajveer Bachkaniwala 创建了 `wsl-clip-bridge`。该方案包含三个部分的修复: 1. **Windows 端程序**:将复制的图片转换为 Linux 可读取的 PNG 格式。 2. **Linux 脚本**:将图片注入 WSL 剪贴板,并设置延迟机制,在 WSL 尝试覆盖数据后重新确认数据。 3. **自定义快捷键**:在 Windows Terminal 中设置自定义快捷键,确保 `Ctrl+V` 命令能传递给 Claude Code,而不是被终端模拟器截获。 完整代码及说明可在 [GitHub](https://github.com/rajveerb/wsl-clip-bridge) 上获取。
相关文章

原文

tl;dr Use Claude Code in WSL inside Windows Terminal? Copying an image in Windows and pressing Ctrl+V in Claude Code doesn't work. Three things break: (1) WSL only hands Windows images to the Linux side in an old BMP format Claude Code can't read; (2) WSL also keeps quietly overwriting your fixes a moment later; (3) Windows Terminal grabs Ctrl+V before Claude Code can see it. The fix is a small Windows program that converts the image to PNG, a Linux script that puts it on the Linux clipboard (and re-asserts once after WSL overwrites it), and one extra keybinding for Claude Code so the keystroke actually reaches the program.

联系我们 contact @ memedata.com