よくある質問(FAQ)
インストール・セットアップ
Q1: tmuxをインストールしたけど、起動できません
A: 以下を確認してください:
# インストール確認
which tmux
# バージョン確認
tmux -V
# PATH が通っているか確認
echo $PATH
macOSの場合は Homebrewで再インストール:
brew reinstall tmux
Q2: 設定ファイルがない場合は?
A: .tmux.conf は必須ではありません。デフォルト設定で動作します。
カスタマイズしたい場合は作成してください:
touch ~/.tmux.conf
Q3: 古いバージョンを使っていますが、新機能が使えません
A: tmuxを最新版に更新してください:
# macOS
brew upgrade tmux
# Ubuntu
sudo apt update && sudo apt upgrade tmux
# ソースからビルド
git clone https://github.com/tmux/tmux.git
cd tmux
./autogen.sh
./configure
make
sudo make install
基本操作
Q4: セッションから抜けたけど、セッションは残っていますか?
A: はい。Ctrl+b d でデタッチしたセッションはバックグラウンドで継続します。
再接続:
tmux attach -t <session-name>
Q5: セッションを完全に終了したい
A: exit コマンドでセッション内のシェルを終了するか、セッションを削除します:
# セッション終了
exit
# または
tmux kill-session -t <session-name>
Q6: ペインを右から左に移動できません
A: 矢印キーで移動できます:
Ctrl+b ← → 左のペインへ
Ctrl+b → → 右のペインへ
または方向キーを設定:
# ~/.tmux.conf
bind-key -n M-h select-pane -L
bind-key -n M-l select-pane -R
Q7: ウィンドウ名が勝手に変わります
A: これは automatic-rename 機能です。無効化:
# ~/.tmux.conf
set-window-option -g automatic-rename off
キーバインド・カスタマイズ
Q8: キーバインドを変更しましたが効きません
A: .tmux.conf 変更後、再読み込みが必要です:
Ctrl+b :
source-file ~/.tmux.conf
Enter
または設定ファイル再読み込みキーバインドを追加:
bind r source-file ~/.tmux.conf
Q9: Ctrl+a をプレフィックスキーに変更したい
A: 以下を .tmux.conf に追加:
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
Q10: Vimのキーバインドを使いたい
A: Vimキー対応設定:
# ~/.tmux.conf
set-window-option -g mode-keys vi
# ペイン移動をVimキーに
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R
# コピーモードをVim風に
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-selection
SSH・リモート接続
Q11: SSH接続がすぐに切れます
A: KeepAliveを設定:
# ~/.ssh/config
Host *
ServerAliveInterval 60
ServerAliveCountMax 10
tmux側でもセッション管理:
# ~/.tmux.conf
set -g session-timeout 0
Q12: ローカルとリモートで同時にtmuxを使っています
A: ネストしたtmuxの場合、外側のプレフィックスキーを2回押します:
Ctrl+b Ctrl+b → 内側のセッションにコマンド送信
または外側のプレフィックスを変更:
# ~/.tmux.conf(ローカル)
set -option -g prefix C-a
# リモートは Ctrl+b のままにしておく
パフォーマンス
Q13: tmuxが遅い・重いです
A: パフォーマンス最適化:
- ステータスバー更新頻度を下げる
set -g status-interval 10
-
不要なプラグインを削除
-
履歴バッファサイズを制限
set -g history-limit 2000
- 画面描画を制限
set -g aggressive-resize off
Q14: 大量のペインを作成してから遅くなりました
A: ペイン数を制限するか、ウィンドウに分けてください:
# 推奨:ペインは最大4-6個まで
# 多い場合は新しいウィンドウを作成
プラグイン
Q15: プラグインがインストールできません
A: TPMがインストールされているか確認:
ls -la ~/.tmux/plugins/tpm
# 未インストールの場合
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
Q16: インストール後のキーバインドがわかりません
A: プラグインのGitHubリポジトリを確認してください:
# 例:tmux-resurrect
# https://github.com/tmux-plugins/tmux-resurrect
トラブル解決
Q17: セッションが応答しなくなりました
A: 以下の順で試してください:
- セッション一覧確認
tmux ls
- 別のウィンドウで確認
tmux capture-pane -t <session> -p
- ウィンドウを削除
tmux kill-window -t <session>:<window>
- セッションを削除
tmux kill-session -t <session>
- 全セッションをリセット(危険)
tmux kill-server
Q18: ペースト時に自動インデントがされて困ります
A: コピー前にペースト時の自動インデント無効化:
# ~/.tmux.conf
bind ] run "xclip -selection clipboard -o | tmux load-buffer -"
または Vimで対処:
:set paste " ペースト前に実行
:set nopaste " ペースト後に実行
Q19: マウスでコピーができません
A: マウス機能を有効化:
# ~/.tmux.conf
set -g mouse on
その後、ドラッグして選択 → 自動コピー
Q20: スクリーンセーバーがtmux内で動きません
A: 画面スリープを無効化:
# tmuxセッション内で
caffeinate -i -s # macOS
またはtmux設定:
# ~/.tmux.conf
set -g lock-command "sleep 100000"
その他
Q21: 複数のプロジェクトを管理したい
A: プロジェクトごとにセッションを作成:
tmux new -s project-a -c ~/projects/a
tmux new -s project-b -c ~/projects/b
# セッション切り替え
tmux attach -t project-a
セッション選択画面を使用:
Ctrl+b s
Q22: シェルスクリプトで自動セットアップしたい
A: セットアップスクリプトを作成:
#!/bin/bash
SESSION="dev"
tmux new-session -d -s $SESSION -c ~/projects
tmux new-window -t $SESSION -n editor
tmux new-window -t $SESSION -n server
tmux send-keys -t $SESSION:editor "vim ." Enter
tmux send-keys -t $SESSION:server "npm start" Enter
tmux attach -t $SESSION
詳しくはワークフローを参照。
Q23: tmuxと Zellij のどちらを使うべき?
A:
- tmux: シンプル、安定、古い環境でも動作
- Zellij: 最新、UI豊富、GPU対応
推奨:初心者は tmux から始めることをお勧めします。
Q24: tmuxの設定をバージョン管理したい
A: .tmux.conf をGitで管理:
git init ~/.tmux
cd ~/.tmux
git config user.email "you@example.com"
git config user.name "Your Name"
mv ~/.tmux.conf ~/.tmux/config
ln -s ~/.tmux/config ~/.tmux.conf
git add config
git commit -m "Initial tmux config"