📓 memotty

TermuxでClaude Code開発を行いたい

TL; DR #

  1. termuxでtmuxセッションを複数起動
  2. 1つ目は純粋なtermuxセッション、Claude Code起動用
  3. その他のセッションはubuntu to termux
    1. vim起動
    2. 開発ローカルサーバー

補足として、ubuntu to termuxを起動するときは必ず開発リポジトリもバインドすること。理由としては

  1. Ubuntu to termux側へ開発リポジトリをバインド
  2. Claude Codeでtermux側のコードを編集
  3. バインドしたubuntu to termuxのコードにも反映
  4. Ubuntu to termux側のvimで内容確認、修正など

といった流れになるためである。
バインドの仕方についてはubuntu to termux内のstartubuntu.shを参考にすること。

試したこと #

ubuntu to termuxでclaude codeの起動 #

だめだった。
welcome to Claude codeと表示された後、大量のnode_modulesエラーが出力される。

原因はubuntu to termuxがProot環境であり、制限が多すぎるためだった。
そもそもClaude Codeが想定する環境は

  • 標準のLinux Desktop
  • GUIあり
  • ネットワークアクセスあり

などなど、いわゆるみんな大好き🍎や🪟といったPCを使用する必要があるのだ。

Proot環境のような軽量な疑似環境は想定されていない。

.tmux.conf #

# シェルを設定
set-option -g default-shell $SHELL

# set prefix key
set -g prefix C-q
unbind C-b

set-option -g history-limit 100000

# enable mouse
set-option -g mouse on
set -g terminal-overrides 'xterm*:smcup@:rmcup@'

# fix remaining word
set -s set-clipboard off

# color
# set -g default-terminal "screen-256color"
# set-option -ga terminal-overrides ",xterm-256color:Tc"
# set -g default-terminal "screen-256color"
# set -g default-terminal "tmux-256color"
# set-option -sa terminal-overrides ",xterm-256color:RGB"
set-option -g default-terminal xterm-256color
set -g terminal-overrides 'xterm:colors=256'

# reduce delay
set -sg escape-time 10
set-option -g repeat-time 500

# index number
set -g base-index 1
set -g pane-base-index 1
setw -g monitor-activity on

# create new window
bind c new-window -c '#{pane_current_path}'
# split window
bind v split-window -h -c '#{pane_current_path}'
bind s split-window -v -c '#{pane_current_path}'

# select pane
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# resize pane
bind -r H resize-pane -L 3
bind -r J resize-pane -D 3
bind -r K resize-pane -U 3
bind -r L resize-pane -R 3

# remove pane
bind q kill-pane

# copy mode vim
set-window-option -g mode-keys vi
bind -T copy-mode-vi v send-keys -X begin-selection

# windows clipboard
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xsel -bi"
# bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"
# bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "pbcopy"