linux:tmux

文書の過去の版を表示しています。


tmux - terminal multiplexer (端末多重接続ソフトウェア)

tmux 画面
本家: 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 UPPage 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 再接続後にアタッチできる。
セッションを確認するには…

$ tmux ls

0: 1 windows (created Thu Jun 11 04:44:30 2020)

$ tmux a
$ tmux a -t 0

$ 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

#マウス操作有効化
set -g mouse on
#スクロールバック行数
set-option -g history-limit 100000

  • linux/tmux.1665748105.txt.gz
  • 最終更新: 2022/10/14 20:48
  • by ともやん