Tmux
Tmux
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-bthend
- 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-bthenc
- Switch to window by number (e.g., window 1):
Ctrl-bthen1
- Rename current window:
Ctrl-bthen,
- Close current window:
Ctrl-dor exit the shell
Pane Management
- Split pane horizontally:
Ctrl-bthen%
- Split pane vertically:
Ctrl-bthen"
- Navigate between panes:
Ctrl-bthen use arrow keys
- Resize panes:
Ctrl-bthen holdCtrland use arrow keys
- Close current pane:
Ctrl-dor 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-btheni
Miscellaneous
- Enter command mode:
Ctrl-bthen:
- Capture pane content to a file:
1
tmux capture-pane -t 0 -S - -E - -p > file.txt
- Scroll mode (copy mode):
Ctrl-bthen[, then navigate using arrow keys,qto exit
Customizing Tmux
- Tmux is highly customizable through the
.tmux.conffile in the user’s home directory. You can set key bindings, appearance, and behavior according to your preference.
This post is licensed under CC BY 4.0 by the author.