文書の表示以前のリビジョンバックリンク文書の先頭へ この文書は読取専用です。文書のソースを閲覧することは可能ですが、変更はできません。もし変更したい場合は管理者に連絡してください。 ~~CLOSETOC~~ ====== tmux - terminal multiplexer (端末多重接続ソフトウェア) ====== {{windows:wsl_tmux.png?470|tmux 画面}}\\ 本家: [[ghi>tmux|Home · tmux/tmux Wiki]] ([[https://github-com.translate.goog/tmux/tmux/wiki?_x_tr_sl=en&_x_tr_tl=ja&_x_tr_hl=ja&_x_tr_pto=sc|翻訳]])\\ ソースコード: [[git>tmux/tmux|tmux/tmux: tmux source code]]\\ ドキュメント: [[rtd>tmuxguide.readthedocs.io|TMUX Guide — TMUX Guide documentation]] ([[https://tmuxguide-readthedocs-io.translate.goog/en/latest/tmux/tmux.html?_x_tr_sl=en&_x_tr_tl=ja&_x_tr_hl=ja&_x_tr_pto=sc|翻訳]])\\ Linux manual: [[https://man7.org/linux/man-pages/man1/tmux.1.html|tmux(1) - Linux manual page]] ([[https://man7-org.translate.goog/linux/man-pages/man1/tmux.1.html?_x_tr_sl=en&_x_tr_tl=ja&_x_tr_hl=ja&_x_tr_pto=sc|翻訳]])\\ Arch Linux: [[arc>Tmux|tmux - ArchWiki]]\\ **tmux** とは、Unix ライクなオペレーティングシステム用の端末多重接続ソフトウェアである。\\ 単一のウィンドウで複数の端末セッションにアクセスできる。同時に複数のコマンドラインプログラムを実行する際に有用である。\\ tmux は制御端末からプロセスを切断することもでき、SSH セッションを SSH 接続をしていない状態でも維持することができる。\\ [[wwjp>Tmux|Wikiwand - Tmux]] より\\ ===== 簡単な基本操作 ===== * **Ctrl + b** を入力後 **?** でキーバインド一覧 * **Ctrl + b** を入力後 **d** でセッションをデタッチ(<wrap em>__セッションを残した状態で tmux 実行前のセッションに戻る__</wrap>) * **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 →** で画面のサイズ変更 ===== セッションのアタッチ ===== <WRAP color_term> <WRAP color_command><html><pre> <b class=BOLD>a</b>ttach-session [<b class=HIK>-dErx</b>] [<b class=HIK>-c</b> <b class=ITA>working-directory</b>] [<b class=HIK>-f</b> <b class=ITA>flags</b>] [<b class=HIK>-t</b> <b class=ITA>target-session</b>] (alias: attach) <b class=GRN>$</b> <b class=HIY>tmux</b> a <b class=GRN>$</b> <b class=HIY>tmux</b> a <b class=HIK>-t</b> 0 </pre></html></WRAP> </WRAP> ===== セッションのデタッチ ===== <WRAP color_term> <WRAP color_command><html><pre> <b class=BOLD>det</b>ach-client <b class=HIK>[-aP] [-E <b class="WHI ITA">shell-command</b>] [-s <b class="WHI ITA">target-session</b>] [-t <b class="WHI ITA">target-client</b>]</b> (alias: detach) <b class=GRN>$</b> <b class=HIY>tmux</b> det -s 0 </pre></html></WRAP> </WRAP> <WRAP color_term> <WRAP color_command><html><pre> <b class=GRN>$</b> <b class=HIY>tmux</b> ls </pre></html></WRAP> <WRAP color_result><html><pre> 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) </pre></html></WRAP> <WRAP color_command><html><pre> <b class=GRN>$</b> <b class=HIY>tmux</b> det -s 1 <b class=GRN>$</b> <b class=HIY>tmux</b> ls </pre></html></WRAP> <WRAP color_result><html><pre> 0: 1 windows (created Fri Oct 14 14:47:17 2022) [110x45] 1: 1 windows (created Fri Oct 14 14:49:39 2022) [237x35] </pre></html></WRAP> </WRAP> ===== セッションのデタッチ ===== * **Ctrl + b** を入力後 **d** で現在のセッションをデタッチ\\ デタッチしたセッションは **ssh** をログアウト後もマシンに残り続ける。 **ssh** 再接続後にアタッチできる。\\ セッションを確認するには...\\ <WRAP color_term> <WRAP color_command><html><pre> <b class=GRN>$</b> <b class=HIY>tmux</b> ls </pre></html></WRAP> <WRAP color_result><html><pre> 0: 1 windows (created Thu Jun 11 04:44:30 2020) </pre></html></WRAP> <WRAP color_command><html><pre> <b class=GRN>$</b> <b class=HIY>tmux</b> a <b class=GRN>$</b> <b class=HIY>tmux</b> a <b class=HIK>-t</b> 0 </pre></html></WRAP> </WRAP> ===== セッションの終了 ===== <WRAP color_term> <WRAP color_command><html><pre> <b class=GRN>$</b> <b class=HIY>tmux</b> ls </pre></html></WRAP> <WRAP color_result><html><pre> 0: 1 windows (created Thu Jun 11 04:44:30 2020) </pre></html></WRAP> <WRAP color_command><html><pre> <b class=GRN>$</b> <b class=HIY>tmux</b> kill-session <b class=GRN>$</b> <b class=HIY>tmux</b> ls </pre></html></WRAP> <WRAP color_result><html><pre> no server running on /tmp/tmux-1000/default </pre></html></WRAP> </WRAP> ===== カスタマイズ ===== <WRAP color_term> <WRAP color_command><html><pre> <b class=GRN>$</b> <b class=HIY>nano</b> ~/.tmux.conf </pre></html></WRAP> <WRAP color_result><html><pre> #マウス操作有効化 set -g mouse on #スクロールバック行数 set-option -g history-limit 100000 </pre></html></WRAP> </WRAP> ===== Python の libtmux で tmux を操作する ===== [[python:libtmux|libtmux - tmux を制御するための Python スクリプトライブラリ]]\\ \\ libtmux をインストールする🤔\\ <WRAP color_term> <WRAP color_command><html><pre> <b class=GRN>$</b> <b class=HIY>pip</b> install <b class=HIK>--user</b> libtmux </pre></html></WRAP> <WRAP color_result><html><pre> Collecting libtmux Downloading libtmux-0.21.0-py3-none-any.whl (47 kB) <b class=PipBAR>━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━</b> <b class=GRN>47.5/47.5 kB</b> <b class=RED>296.3 kB/s</b> eta <b class=CYN>0:00:00</b> Installing collected packages: libtmux Successfully installed libtmux-0.21.0 </pre></html></WRAP> </WRAP> ptpython をインストールする🤔\\ <WRAP color_term> <WRAP color_command><html><pre> <b class=GRN>$</b> <b class=HIY>pip</b> install <b class=HIK>--user</b> ptpython </pre></html></WRAP> <WRAP color_result><html><pre> Collecting ptpython Downloading ptpython-3.0.23-py2.py3-none-any.whl (63 kB) <b class=PipBAR>━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━</b> <b class=GRN>64.0/64.0 kB</b> <b class=RED>340.0 kB/s</b> eta <b class=CYN>0:00:00</b> Collecting appdirs Downloading appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB) Collecting jedi>=0.16.0 Using cached jedi-0.18.2-py2.py3-none-any.whl (1.6 MB) Collecting prompt-toolkit<3.1.0,>=3.0.28 Using cached prompt_toolkit-3.0.38-py3-none-any.whl (385 kB) Collecting pygments Using cached Pygments-2.14.0-py3-none-any.whl (1.1 MB) Collecting parso<0.9.0,>=0.8.0 Using cached parso-0.8.3-py2.py3-none-any.whl (100 kB) Collecting wcwidth Using cached wcwidth-0.2.6-py2.py3-none-any.whl (29 kB) Installing collected packages: wcwidth, appdirs, pygments, prompt-toolkit, parso, jedi, ptpython Successfully installed appdirs-1.4.4 jedi-0.18.2 parso-0.8.3 prompt-toolkit-3.0.38 ptpython-3.0.23 pygments-2.14.0 wcwidth-0.2.6 </pre></html></WRAP> </WRAP> ===== 参考文献 ===== [[https://wiki.archlinux.jp/index.php/Tmux|tmux - ArchWiki]]\\ [[https://libtmux.git-pull.com|libtmux]]\\ [[https://www.hostinger.com/tutorials/tmux-beginners-guide-and-cheat-sheet/|tmux: How to Install and Use It + Cheat Sheet]] ([[https://www-hostinger-com.translate.goog/tutorials/tmux-beginners-guide-and-cheat-sheet/?_x_tr_sl=en&_x_tr_tl=ja&_x_tr_hl=ja&_x_tr_pto=sc|翻訳]])\\ ==== 付録 ==== [[tw>tomoyan596sp/status/1636109800965828608|tmuxをpythonから操作するのに、このようなライブラリが存在していても、国内の検索上位は「5年が経過しています」だそうです😅海外の動向しか見ないことにしてます🤔]]\\ linux/tmux.txt 最終更新: 2023/04/23 07:07by ともやん