Tmux Cheat Sheet
Quick reference for tmux sessions, windows, panes, copy-mode, configuration snippets, workflows, plugins and troubleshooting. Printable and accessible.
Basics
Prefix (default): Ctrl+b. Replace with your chosen prefix if remapped.
tmux new -s <name>— start a new sessiontmux ls— list sessionstmux attach -t <name>— attach to a sessiontmux kill-session -t <name>— kill a sessionPrefix d— detach from session
Sessions & Windows
Window and session management commands.
Prefix c— create a new windowPrefix ,— rename current windowPrefix &— kill current windowPrefix w— list windowsPrefix n / p— next / previous windowtmux new-session -d -s <name>— start detached
Panes
Splitting and pane manipulation.
Prefix %— split vertical (right)Prefix "— split horizontal (below)Prefix x— kill current panePrefix o— cycle panesPrefix ;— go to last active panePrefix q— show pane numbers (for direct selection)
Copy & Paste
Using tmux copy-mode, buffers and mouse integration.
Prefix [— enter copy-mode- Select text: move cursor, press
Space, move to end, pressEnterto copy Prefix ]— paste top buffer- List buffers:
Prefix : list-buffers; paste specific buffer:Prefix : paste-buffer -b <N> - Enable mouse:
set -g mouse on(tmux >= 2.1) — allows clicking, selection and resize with mouse
Sync panes
Broadcast input to all panes in a window.
- On:
Prefix : setw synchronize-panes on - Off:
Prefix : setw synchronize-panes off
Useful .tmux.conf snippets
Place these in ~/.tmux.conf.
# Set prefix to Ctrl-a (optional)
unbind C-b
set -g prefix C-a
bind C-a send-prefix
# Use vi keys in copy mode
setw -g mode-keys vi
# Increase scrollback
set -g history-limit 20000
# Enable mouse
set -g mouse on
# Colors and 256-colors support
set -g default-terminal "screen-256color"
# Reload config quickly
bind r source-file ~/.tmux.conf \; display-message "tmux: config reloaded"
Plugins & Tools
- tpm — Tmux Plugin Manager (install and manage plugins)
- tmux-resurrect / tmux-continuum — save & restore sessions
- tmuxinator, teamocil, tmuxp — project/session layout tools
Example tmuxinator snippet:
# ~/.tmuxinator/project.yml
name: deploy
root: ~/projects/myapp
windows:
- editor:
layout: even-vertical
panes:
- vim
- guard
- server: bundle exec rails s
Workflows & Examples
- Share a session: attach the same named session from multiple ttys or allow trusted users to attach via SSH:
tmux attach -t shared - Detached starter: have systemd start a session on boot:
tmux new -d -s mysession 'cd /srv && bash' - Remote reconnect:
ssh -t host tmux attach -t name - Logging: run multiple tails across panes for live debugging
Advanced
- Hooks:
set-hook -g after-new-window 'display-message "New window created"' - Scripting: use format strings:
tmux display-message -p '#{session_name}' - Layouts: save/restore via
tmux list-windows -F '#{window_layout}'andtmux select-layout - Session groups: mirror windows across sessions with
link-window
Troubleshooting & Tips
- $TERM & keys: prefer
screen-256colorortmux-256color. Some terminals requirexterm-256color. - Clipboard: integrate system clipboard via
tmux save-buffer - | xclip -selection clipboardor copy-pipe settings per platform. - Colors broken: set
set -g default-terminal "screen-256color"and check emulator settings. - Session restore: verify tmux-resurrect versions and paths.
Quick Reference
- New session
tmux new -s <name>- Detach
Prefix d- Split
Prefix %(vertical),Prefix "(horizontal)- Copy mode
Prefix [→ select →Enter- Reload config
Prefix r(if bound)
This page is printable! Use Print → Save as PDF to get the printable version!