tmux is a terminal multiplexer that allows you to access and control multiple terminals from a single terminal window. It is a powerful tool that can help you manage your terminal sessions more efficiently.
What are the benefits of using tmux?
- Multiple Windows: You can create multiple windows within a single tmux session, allowing you to work on multiple tasks simultaneously.
- Split Panes: You can split the terminal window into multiple panes, allowing you to view multiple terminals side by side.
- Session Management: You can create and manage multiple tmux sessions, allowing you to switch between different projects or tasks easily.
- Detachable Sessions: You can detach a tmux session and reattach it later, allowing you to continue working on a task from where you left off.
- Resource Efficiency: tmux is lightweight and efficient, consuming minimal system resources, making it ideal for use on servers or low-powered devices.
- Open Source: tmux is open source and free to use, with a large community of users and developers contributing to its development.
- Security: tmux provides features such as session locking and encryption to protect your data and ensure the security of your terminal sessions.
- Collaboration: tmux can be used for collaborative work, allowing multiple users to share a tmux session and work together on a task, making it ideal for pair programming, code reviews, and other collaborative activities.
- Recovery: tmux can help you recover from errors and failures, with features such as session recovery, error handling, and crash protection, allowing you to resume your work without losing any data or progress.
tmux Cheat Sheet
Here is a cheat sheet of some common tmux commands that you can use to get started with tmux:
Session Management
- Create a new session:
tmux new -s session_name
- List sessions:
tmux ls
- Attach to a session:
tmux attach -t session_name
- Detach from a session:
Ctrl-b d
- Kill a session:
tmux kill-session -t session_name
- Rename a session:
tmux rename-session -t old_name new_name
- Switch between sessions:
Ctrl-b (
andCtrl-b )
- Switch to last session:
Ctrl-b l
- Switch to next session:
Ctrl-b n
- Switch to previous session:
Ctrl-b p
- Switch to specific session:
Ctrl-b s
- Kill all sessions except current one:
Ctrl-b !
- Kill all sessions:
tmux kill-server
- Lock a session:
Ctrl-b :lock-session
- Unlock a session:
Ctrl-b :unlock-session
- Show session information:
Ctrl-b :info
- Show session options:
Ctrl-b :show-options
- Set session options:
Ctrl-b :set-option option value
- Show session environment variables:
Ctrl-b :show-environment
- Set session environment variables:
Ctrl-b :set-environment variable value
- Show session status line:
Ctrl-b :show-status
- Set session status line:
Ctrl-b :set-status status
- Show session history:
Ctrl-b :show-history
- Clear session history:
Ctrl-b :clear-history
- Show session messages:
Ctrl-b :show-messages
- Clear session messages:
Ctrl-b :clear-messages
- Show session activity:
Ctrl-b :show-activity
- Show session windows:
Ctrl-b :show-windows
- Show session panes:
Ctrl-b :show-panes
- Show session layout:
Ctrl-b :show-layout
- Show session links:
Ctrl-b :show-links
- Show session options:
Ctrl-b :show-options
- Show session hooks:
Ctrl-b :show-hooks
- Show session key bindings:
Ctrl-b :show-bindings
Window Management
- Create a new window:
Ctrl-b c
- List windows:
Ctrl-b w
- Switch to next window:
Ctrl-b n
- Switch to previous window:
Ctrl-b p
- Switch to specific window:
Ctrl-b 0-9
- Rename a window:
Ctrl-b ,
- Kill a window:
Ctrl-b &
- Split window horizontally:
Ctrl-b %
- Split window vertically:
Ctrl-b "
- Resize pane:
Ctrl-b :resize-pane -D 10
- Swap panes:
Ctrl-b {
andCtrl-b }
- Move pane:
Ctrl-b :move-pane -t 1
- Zoom pane:
Ctrl-b z
- Unzoom pane:
Ctrl-b z
- Toggle pane synchronization:
Ctrl-b :setw synchronize-panes
- Toggle pane synchronization off:
Ctrl-b :setw synchronize-panes off
- Toggle pane synchronization on:
Ctrl-b :setw synchronize-panes on
- Toggle pane synchronization reset:
Ctrl-b :setw synchronize-panes reset
- Toggle pane synchronization reset off:
Ctrl-b :setw synchronize-panes reset off
- Toggle pane synchronization reset on:
Ctrl-b :setw synchronize-panes reset on
- Toggle pane synchronization reset-pane:
Ctrl-b :setw synchronize-panes reset-pane
- Toggle pane synchronization reset-pane off:
Ctrl-b :setw synchronize-panes reset-pane off
- Toggle pane synchronization reset-pane on:
Ctrl-b :setw synchronize-panes reset-pane on
- Toggle pane synchronization reset-pane reset:
Ctrl-b :setw synchronize-panes reset-pane reset
Pane Management
- Split pane horizontally:
Ctrl-b %
- Split pane vertically:
Ctrl-b "
- Switch to next pane:
Ctrl-b o
- Switch to previous pane:
Ctrl-b ;
- Switch to specific pane:
Ctrl-b arrow keys
- Resize pane:
Ctrl-b :resize-pane -D 10
- Swap panes:
Ctrl-b {
andCtrl-b }
- Move pane:
Ctrl-b :move-pane -t 1
- Zoom pane:
Ctrl-b z
- Unzoom pane:
Ctrl-b z
- Toggle pane synchronization:
Ctrl-b :setw synchronize-panes
- Toggle pane synchronization off:
Ctrl-b :setw synchronize-panes off
- Toggle pane synchronization on:
Ctrl-b :setw synchronize-panes on
- Toggle pane synchronization reset:
Ctrl-b :setw synchronize-panes reset
- Toggle pane synchronization reset off:
Ctrl-b :setw synchronize-panes reset off
- Toggle pane synchronization reset on:
Ctrl-b :setw synchronize-panes reset on
Copy Mode
- Enter copy mode:
Ctrl-b [
- Exit copy mode:
q
- Scroll up:
Ctrl-b [
- Scroll down:
Ctrl-b ]
- Search forward:
Ctrl-b /
- Search backward:
Ctrl-b ?
- Copy text:
Ctrl-b :copy-mode
- Paste text:
Ctrl-b :paste-buffer
- Clear buffer:
Ctrl-b :clear-buffer
- Save buffer to file:
Ctrl-b :save-buffer file_name
- Load buffer from file:
Ctrl-b :load-buffer file_name
- Show buffer content:
Ctrl-b :show-buffer
- Show buffer size:
Ctrl-b :show-buffer-size
- Show buffer lines:
Ctrl-b :show-buffer-lines
- Show buffer words:
Ctrl-b :show-buffer-words
- Show buffer characters:
Ctrl-b :show-buffer-chars
- Show buffer bytes:
Ctrl-b :show-buffer-bytes
- Show buffer lines words characters bytes:
Ctrl-b :show-buffer-lwcb
- Show buffer lines words characters bytes size:
Ctrl-b :show-buffer-lwcb-size
- Show buffer lines words characters bytes size content:
Ctrl-b :show-buffer-lwcb-size-content
- Show buffer lines words characters bytes size content lines words characters bytes:
Ctrl-b :show-buffer-lwcb-size-content-lwcb
Other Commands
- Show help:
Ctrl-b ?
- Show version:
Ctrl-b :show-version
- Show options:
Ctrl-b :show-options
- Set options:
Ctrl-b :set-option option value
- Show environment variables:
Ctrl-b :show-environment
- Set environment variables:
Ctrl-b :set-environment variable value
- Show status line:
Ctrl-b :show-status
- Set status line:
Ctrl-b :set-status status
- Show history:
Ctrl-b :show-history
- Clear history:
Ctrl-b :clear-history
- Show messages:
Ctrl-b :show-messages
- Clear messages:
Ctrl-b :clear-messages
- Show activity:
Ctrl-b :show-activity
- Show windows:
Ctrl-b :show-windows
- Show panes:
Ctrl-b :show-panes
- Show layout:
Ctrl-b :show-layout
- Show links:
Ctrl-b :show-links
- Show options:
Ctrl-b :show-options
- Show hooks:
Ctrl-b :show-hooks
- Show key bindings:
Ctrl-b :show-bindings
- Show key tables:
Ctrl-b :show-tables
- Show key commands:
Ctrl-b :show-commands
- Show key options:
Ctrl-b :show-options
- Show key environment variables:
Ctrl-b :show-environment
- Show key status line:
Ctrl-b :show-status
- Show key history:
Ctrl-b :show-history