Introduction to tmux Terminal Multiplexer
Tmux (terminal multiplexer) is a powerful terminal multiplexer that allows users to access multiple independent sessions within a single terminal window, as well as detach from and reattach to sessions. With tmux, you can disconnect from a session without interrupting running processes and reconnect later. Here is a basic guide on using tmux on Unix-like systems:
-
Install tmux: On most Unix-like operating systems, you can install tmux using the package manager. For example, on Debian or Ubuntu:
sudo apt update
sudo apt install tmux -
Start tmux: Enter the
tmuxcommand to start a tmux session:tmuxIf you want to start a session with a specific name:
tmux new -s my_sessionThis makes it easier to remember and manage your sessions.
-
tmux session control
tmux ls: List all current tmux sessions.tmux attach -t my_session: Reattach to the session namedmy_session.tmux kill-session -t my_session: Kill the session namedmy_session.
-
Split panes
Ctrl+b ": Split the current pane horizontally.Ctrl+b %: Split the current pane vertically.
-
Switch panes
Ctrl+b arrow keys: Use the arrow keys to switch between panes.Ctrl+b o: Cycle to the next pane.
-
Resize panes
Ctrl+bthenarrow keys: HoldCtrl+band press the arrow keys to resize the pane.
-
Window (tab-like) management
Ctrl+b c: Create a new window.Ctrl+b p: Switch to the previous window.Ctrl+b n: Switch to the next window.Ctrl+b number: Switch to the window with the specified number, wherenumberis the zero-based window index.
-
Detach from a session
Ctrl+b d: Detach from the current session. This allows you to close the terminal without ending the tmux session.
-
Customize tmux You can customize tmux by editing the
~/.tmux.confconfiguration file. -
Exit tmux
- Without split panes, simply type
exitor pressCtrl+dto exit. - If there are multiple panes, you need to exit from each pane individually.
- Without split panes, simply type
The above covers some basic tmux usage. tmux is very powerful and includes, but is not limited to, session management, window and pane management, custom keybindings, scripting, and automation. It is recommended to read the manual (man tmux) or a more detailed tutorial to fully understand all its features.