1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

WSL + Ubuntu で Claude Code + Typeless を使う

1
Last updated at Posted at 2026-03-04

WSL(Windows Subsystem for Linux)上の Ubuntu で Claude Code を使うとき、画像ペーストTypeless(音声入力)のテキストペーストCtrl+V を奪い合って共存できない問題がある。この記事ではその解決方法をまとめる。

問題

Claude Code は画像ペーストに Ctrl+V を使う。内部的には xclip コマンドでクリップボードを読みに行くが、WSL の xclip は Windows 側のクリップボードの画像を読めない。

さらに Typeless(音声入力ツール)もテキストのペーストに Ctrl+V を送信するため、キーが衝突する。

解決の方針

  • Claude Code の画像ペーストAlt+V に変更
  • Typeless のテキストペーストCtrl+V(Windows Terminal のペースト)
  • xclip ラッパー → PowerShell 経由で Windows 側のクリップボード画像を取得

手順

1. xclip をインストール

sudo apt install xclip

本物の xclip を入れておく。ラッパーから委譲先として使う。

2. xclip ラッパーを作成

~/.local/bin/xclip に以下のスクリプトを作成する。

Claude Code が内部で叩く xclip の呼び出しをフックして、Windows 側のクリップボードから画像を取得する仕組み。

mkdir -p ~/.local/bin

cat << 'EOF' > ~/.local/bin/xclip
#!/bin/bash

# TARGETS チェック(Claude Code が画像の有無を確認する)
if [[ "$*" == *"-t TARGETS"* && "$*" == *"-o"* ]]; then
  result=$(/usr/bin/xclip "$@" 2>/dev/null)
  if echo "$result" | grep -q "image/"; then
    echo "$result"
  else
    # Windows 側のクリップボードを確認
    has_image=$(powershell.exe -NoProfile -Command '
      Add-Type -AssemblyName System.Windows.Forms
      if ([System.Windows.Forms.Clipboard]::ContainsImage()) { Write-Output "yes" }
    ' 2>/dev/null | tr -d '\r')
    if [ "$has_image" = "yes" ]; then
      echo -e "image/png\nTARGETS"
    else
      /usr/bin/xclip "$@" 2>/dev/null
    fi
  fi
# 画像データ取得
elif [[ "$*" == *"-t image/"* && "$*" == *"-o"* ]]; then
  powershell.exe -NoProfile -Command '
    Add-Type -AssemblyName System.Windows.Forms
    $img = [System.Windows.Forms.Clipboard]::GetImage()
    if ($img) {
      $ms = New-Object System.IO.MemoryStream
      $img.Save($ms, [System.Drawing.Imaging.ImageFormat]::Png)
      [Console]::OpenStandardOutput().Write($ms.ToArray(), 0, $ms.Length)
    }' 2>/dev/null
# それ以外は本物の xclip に委譲
else
  /usr/bin/xclip "$@"
fi
EOF

chmod +x ~/.local/bin/xclip

3. PATH を設定

.bashrc でラッパーが /usr/bin/xclip より先に見つかるようにする。

export PATH="$HOME/.local/bin:$PATH"

確認:

which xclip
# → /home/<user>/.local/bin/xclip ならOK

4. Claude Code のキーバインドを変更

画像ペーストを Alt+V に変更して、Ctrl+V を Typeless に譲る。

~/.claude/keybindings.json を作成:

{
  "$schema": "https://www.schemastore.org/claude-code-keybindings.json",
  "bindings": [
    {
      "context": "Chat",
      "bindings": {
        "ctrl+v": null,
        "alt+v": "chat:pasteImage"
      }
    }
  ]
}

5. Windows Terminal のキーバインドを設定

Typeless が Ctrl+V でテキストをペーストできるように、Windows Terminal に Ctrl+V のペーストバインドを追加する。

Windows Terminal の settings.json に以下を追加:

"keybindings": [
    {
        "id": "User.paste",
        "keys": "ctrl+v"
    }
]

6. 動作確認

Windows 側でスクリーンショットをクリップボードにコピーしてから:

# TARGETS 確認
xclip -selection clipboard -t TARGETS -o
# → image/png が出ればOK

# 画像データ取得確認
xclip -selection clipboard -t image/png -o > /tmp/test.png
file /tmp/test.png
# → PNG image data... ならOK

# Claude Code で Alt+V → 画像が添付されれば成功

まとめ

キー 動作
Alt+V Claude Code の画像ペースト
Ctrl+V Typeless のテキストペースト(Windows Terminal 経由)
Ctrl+Shift+V ターミナルのテキストペースト

本質は「WSL の xclip は Windows 側クリップボードの画像を読めない」という問題を PowerShell ブリッジで解決しているだけ。Typeless との共存はキーバインドの棲み分けで対処する。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?