目次
文書の過去の版を表示しています。
tmux - terminal multiplexer (端末多重接続ソフトウェア)
本家: Home · tmux/tmux Wiki
ソースコード: tmux/tmux: tmux source code
tmux とは、Unix ライクなオペレーティングシステム用の端末多重接続ソフトウェアである。
単一のウィンドウで複数の端末セッションにアクセスできる。同時に複数のコマンドラインプログラムを実行する際に有用である。
tmux は制御端末からプロセスを切断することもでき、SSH セッションを SSH 接続をしていない状態でも維持することができる。
tmux - Wikipedia より
簡単な基本操作
- Ctrl + b を入力後 ? でキーバインド一覧
- Ctrl + b を入力後 d でセッションをデタッチ(セッションを残した状態で tmux 実行前のセッションに戻る)
- Ctrl + b を入力後 Shift + 2 (“) で上下に分割
- Ctrl + b を入力後 Shift + 5 (%) で左右に分割
- Ctrl + b を入力後 ↑ or ↓ or ← or → でペイン移動
- Ctrl + b を入力後 Space を繰り返すとお好みのレイアウトに
- Ctrl + b を入力後 [ で ↑ (上スクロール)、↓ (下スクロール)、Page UP、Page Down
- Ctrl + b を入力後 { で前の画面に入れ替え
- Ctrl + b を入力後 } で後の画面に入れ替え
- Ctrl + b を入力後 Ctrl + ↑ or ↓ or ← or → で画面のサイズ変更
セッションのアタッチ
attach-session [-dErx] [-c working-directory] [-f flags] [-t target-session] (alias: attach) $ tmux a $ tmux a -t 0
セッションのデタッチ
detach-client [-aP] [-E shell-command] [-s target-session] [-t target-client] (alias: detach) $ tmux det -s 0
$ tmux ls
0: 1 windows (created Fri Oct 14 14:47:17 2022) [110x45] 1: 1 windows (created Fri Oct 14 14:49:39 2022) [237x35] (attached)
$ tmux det -s 1 $ tmux ls
0: 1 windows (created Fri Oct 14 14:47:17 2022) [110x45] 1: 1 windows (created Fri Oct 14 14:49:39 2022) [237x35]
セッションのデタッチ
- Ctrl + b を入力後 d で現在のセッションをデタッチ
デタッチしたセッションは ssh をログアウト後もマシンに残り続ける。
ssh 再接続後にアタッチできる。
セッションを確認するには…
list-sessions [-F format] [-f filter] (alias: ls) $ tmux ls
0: 1 windows (created Thu Jun 11 04:44:30 2020)
セッションの終了
$ tmux ls
0: 1 windows (created Thu Jun 11 04:44:30 2020)
$ tmux kill-session $ tmux ls
no server running on /tmp/tmux-1000/default
カスタマイズ
$ nano ~/.tmux.conf