Catalog / tmux Cheatsheet
tmux Cheatsheet
A comprehensive guide to using tmux, the terminal multiplexer. This cheatsheet covers essential commands, session management, window and pane manipulation, and customization options to enhance your workflow.
Getting Started with tmux
Basic Concepts
What is tmux? |
Key Binding Prefix |
Starting and Ending Sessions
|
Starts a new tmux session. |
|
Starts a new named session. |
|
Attaches to the default session. |
|
Attaches to a specific session. |
|
Detaches the current session (leaves tmux running in the background). |
|
Closes the current pane/window. Closes the session if it’s the last one. |
Basic Navigation
|
Shows the help screen with available key bindings. |
|
Lists all tmux sessions and allows switching between them. |
|
Lists all active tmux sessions (from the command line). |
Working with Windows and Panes
Window Management
|
Creates a new window. |
|
Renames the current window. |
|
Goes to the next window. |
|
Goes to the previous window. |
|
Goes to the specified window number. |
|
Displays a list of windows for selection. |
|
Kills the current window (prompts for confirmation). |
Pane Management
|
Splits the current pane horizontally. |
|
Splits the current pane vertically. |
|
Moves to the pane in the direction of the arrow key (up, down, left, right). |
|
Moves to the next pane. |
|
Swaps the current pane with the previous pane. |
|
Swaps the current pane with the next pane. |
|
Kills the current pane (prompts for confirmation). |
|
Breaks the current pane out into a new window. |
|
Briefly displays pane numbers, allowing you to jump to a specific pane by pressing its number. |
Advanced Features and Customization
Copy Mode and Scrolling
|
Enters copy mode, allowing you to scroll and copy text. |
|
Pastes the last copied text. |
|
In copy mode, starts text selection. |
|
In copy mode, copies the selected text. |
|
Exits copy mode. |
|
In copy mode, enters search mode to find text within the buffer. |
|
In copy/search mode, goes to the next/previous search result. |
Configuration
tmux behavior can be configured through the Example Configuration:
|
Useful settings for .tmux.conf
|
Enables mouse support for pane selection, resizing and scrolling. |
|
Sets the default terminal type for better color support. |
|
Binds |
|
Positions the status bar at the top of the screen. |
|
Automatically renames windows based on the running program. |
|
Increase the history limit |
Status Bar Customization
Status Bar Options
|
Justifies the status bar content. |
|
Sets the content for the left side of the status bar. |
|
Sets the content for the right side of the status bar. |
|
Sets the background and foreground colors for the entire status bar. |
|
Sets the style for inactive windows in the status bar. |
|
Sets the style for the active window in the status bar. |
Status Bar Variables
|
Executes a shell command and displays its output. |
|
Displays the window index. |
|
Displays the session name. |
|
Displays the window name. |
|
Displays the hostname. |
|
Displays the pane title. |
Status Bar Examples
Example Status Bar Configuration
This configuration sets a black background and white foreground for the status bar, displays the session name, window index, and pane index on the left, and the current date and time on the right. |