Tmux Reference
Free reference guide: Tmux Reference
About Tmux Reference
The Tmux Reference is a searchable cheat sheet for tmux, the terminal multiplexer that lets you manage multiple terminal sessions within a single window. It covers the complete hierarchy of tmux objects: sessions that persist across SSH disconnections, windows that act as tabs within a session, and panes that split a window into multiple terminal views -- all controlled through the Ctrl+b prefix key.
This reference organizes over 50 key bindings and commands across five categories: Sessions, Windows, Panes, Key Bindings, and Copy Mode. The Sessions section covers creating named sessions with tmux new -s, listing with tmux ls, attaching and detaching, and navigating between sessions. The Windows section includes creating, renaming, switching by number or name, and closing windows. The Panes section details vertical and horizontal splitting, directional navigation, resizing, zooming, and rearranging pane layouts.
Beyond basic navigation, this cheat sheet covers copy mode with Vi-style movement keys for scrolling through terminal output, text selection and copying with the tmux paste buffer, and essential tmux.conf customizations including changing the prefix key to Ctrl+a, enabling mouse support, and reloading configuration without restarting the server. These are the commands and shortcuts that experienced developers use daily for efficient terminal workflow management.
Key Features
- Session management: create named sessions, list, attach, detach, rename, kill, and switch between sessions
- Window operations: create, rename, switch by number (0-9), navigate next/previous, find by name, and close windows
- Pane splitting and navigation: vertical (%) and horizontal (") splits with directional movement and resize controls
- Pane manipulation: zoom toggle (z), break pane to window (!), swap positions ({/}), and cycle layouts (Space)
- Copy mode with Vi-style navigation: scroll output, search forward/backward, select text, and paste from buffer
- tmux.conf customization: prefix key remapping, mouse support, and live configuration reload with source-file
- Session persistence across SSH disconnections with detach (d) and reattach (tmux attach -t)
- Complete key binding reference with Ctrl+b prefix for all session, window, and pane operations
Frequently Asked Questions
What is the tmux prefix key and how do I use it?
The default prefix key is Ctrl+b. Press Ctrl+b first, release it, then press the command key. For example, Ctrl+b c creates a new window, Ctrl+b % splits vertically, and Ctrl+b d detaches from the session. You can change the prefix to Ctrl+a by adding set -g prefix C-a to your ~/.tmux.conf file, which many users prefer since it is closer to the home row.
How do I split the terminal into multiple panes?
Use Ctrl+b % for a vertical split (left/right) and Ctrl+b " for a horizontal split (top/bottom). Navigate between panes with Ctrl+b followed by arrow keys, or Ctrl+b o to cycle through them. Resize panes with Ctrl+b Ctrl+Arrow. Press Ctrl+b z to toggle a pane to fullscreen and back, which is useful when you need to focus on one pane temporarily.
How do sessions persist when I disconnect from SSH?
When you detach from a tmux session (Ctrl+b d) or lose your SSH connection, the session continues running on the server. All running processes, terminal output, and pane layouts are preserved. Reconnect via SSH and run tmux attach -t <session-name> to resume exactly where you left off. This makes tmux essential for long-running processes on remote servers.
How do I copy text from terminal output in tmux?
Press Ctrl+b [ to enter copy mode. Navigate using Vi keys (h/j/k/l) or arrow keys. Press Space to start selection, move to expand it, then press Enter to copy and exit copy mode. Paste with Ctrl+b ]. For searching, use / to search forward or ? to search backward within the scrollback buffer. Press g to jump to the top or G to jump to the bottom of the buffer.
How do I manage multiple tmux sessions?
Create named sessions with tmux new -s <name>. List all sessions with tmux ls. Switch between sessions using Ctrl+b s which shows an interactive session list, or use Ctrl+b ( and Ctrl+b ) to move to the previous/next session. Kill a specific session with tmux kill-session -t <name>. Use tmux kill-server to terminate all sessions at once.
How do I customize tmux with the configuration file?
Create or edit ~/.tmux.conf with your settings. Common customizations include set -g prefix C-a to change the prefix key, set -g mouse on to enable mouse support for pane selection and resizing, and bind keys for custom shortcuts. After editing, reload the configuration with tmux source-file ~/.tmux.conf without needing to restart tmux or lose your sessions.
What is the difference between windows and panes?
Windows are like tabs -- each window occupies the full terminal screen and you switch between them with Ctrl+b n (next), Ctrl+b p (previous), or Ctrl+b <number>. Panes are subdivisions within a window, created by splitting. You can have multiple panes visible simultaneously side by side or stacked. Use Ctrl+b ! to break a pane out into its own window if needed.
How do I resize panes in tmux?
Hold Ctrl+b and then press Ctrl+Arrow keys (up/down/left/right) to resize the active pane in that direction. Alternatively, press Ctrl+b Space to cycle through preset layouts (even-horizontal, even-vertical, main-horizontal, main-vertical, tiled). If mouse support is enabled with set -g mouse on, you can also drag pane borders with the mouse to resize them interactively.