Introduction
Tmux is a terminal multiplexer that allows you to manage multiple terminal sessions from a single window. It’s extremely useful for developers and system administrators for multitasking in the command line environment.
Install Tmux using Homebrew:
1
brew install tmux
Tmux Shortcuts and Commands
Starting, Detaching, and Attaching Sessions
- Start new session:
1
tmux
- Start new named session:
1
tmux new -s session_name
- Detach from session:
Ctrl-b
thend
- List sessions:
1
tmux ls
- Attach to session:
1
tmux attach -t session_name
- Attach to the last session:
1
tmux a
Window Management
- Create new window:
Ctrl-b
thenc
- Switch to window by number (e.g., window 1):
Ctrl-b
then1
- Rename current window:
Ctrl-b
then,
- Close current window:
Ctrl-d
or exit the shell
Pane Management
- Split pane horizontally:
Ctrl-b
then%
- Split pane vertically:
Ctrl-b
then"
- Navigate between panes:
Ctrl-b
then use arrow keys
- Resize panes:
Ctrl-b
then holdCtrl
and use arrow keys
- Close current pane:
Ctrl-d
or exit the shell in the pane
Session Environment
- Reload tmux configuration:
1
tmux source-file ~/.tmux.conf
- Show all key bindings:
1
tmux list-keys
- Show system information:
Ctrl-b
theni
Miscellaneous
- Enter command mode:
Ctrl-b
then:
- Capture pane content to a file:
1
tmux capture-pane -t 0 -S - -E - -p > file.txt
- Scroll mode (copy mode):
Ctrl-b
then[
, then navigate using arrow keys,q
to exit
Customizing Tmux
- Tmux is highly customizable through the
.tmux.conf
file in the user’s home directory. You can set key bindings, appearance, and behavior according to your preference.