tmux lets you keep terminal sessions running, split windows, and reconnect later.
Default prefix key:
Ctrl + bAfter pressing Ctrl + b, release both keys, then press the command key.
Create a new session:
tmuxCreate a named session:
tmux new -s myprojectList sessions:
tmux lsAttach to a session:
tmux attach -t myprojectDetach from current session:
Ctrl + b, then d
Kill a session:
tmux kill-session -t myprojectRename current session:
Ctrl + b, then $
A tmux window is like a terminal tab.
Create new window:
Ctrl + b, then c
Switch to next window:
Ctrl + b, then n
Switch to previous window:
Ctrl + b, then p
Switch to window by number:
Ctrl + b, then 0
Ctrl + b, then 1
Ctrl + b, then 2
Rename current window:
Ctrl + b, then ,
Close current window:
Ctrl + b, then &
Show window list:
Ctrl + b, then w
A tmux pane is a split inside a window.
Split vertically, left/right:
Ctrl + b, then %
Split horizontally, top/bottom:
Ctrl + b, then "
Move between panes:
Ctrl + b, then arrow key
Close current pane:
Ctrl + b, then x
Zoom current pane fullscreen:
Ctrl + b, then z
Resize pane:
Ctrl + b, then hold Ctrl + arrow key
Show pane numbers:
Ctrl + b, then q
Convert pane to new window:
Ctrl + b, then !
Enter scroll/copy mode:
Ctrl + b, then [
Move around:
Arrow keys
Page Up
Page Down
Quit copy mode:
q
Search in scrollback:
Ctrl + b, then [
/search-text
Enter
Show all key bindings:
tmux list-keysShow all sessions:
tmux list-sessionsShow all windows:
tmux list-windowsShow all panes:
tmux list-panesReload tmux config:
tmux source-file ~/.tmux.confFor one project:
tmux new -s orderbuddyThen use windows like this:
Window 1: editor
Window 2: dev server
Window 3: tests
Window 4: logs
Window 5: git
Example:
Ctrl + b, c # new window
Ctrl + b, , # rename it
Names:
code
server
tests
logs
git
Detach when finished:
Ctrl + b, d
Later reconnect:
tmux attach -t orderbuddyCreate or edit:
nano ~/.tmux.confAdd:
# Use mouse for pane selection, resizing, and scrolling
set -g mouse on
# Start window and pane numbering at 1
set -g base-index 1
setw -g pane-base-index 1
# Larger scrollback history
set -g history-limit 50000
# Better colors
set -g default-terminal "screen-256color"
# Reload config with Prefix + r
bind r source-file ~/.tmux.conf \; display-message "tmux config reloaded"
# Easier pane splitting
bind | split-window -h
bind - split-window -v
# Move between panes using vim-style keys
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Resize panes
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5Reload:
tmux source-file ~/.tmux.confNow you can use:
Ctrl + b, |
Ctrl + b, -
Ctrl + b, h/j/k/l
Ctrl + b, r
Use named sessions. Instead of just running tmux, use:
tmux new -s appnameThis makes it much easier to reconnect later.
Use one session per project. For example:
tmux new -s orderbuddy
tmux new -s ai-agent
tmux new -s firebase-testUse tmux for long-running tasks:
npm run dev
npm test -- --watch
firebase emulators:start
docker compose up
tail -f app.logDetach safely with:
Ctrl + b, d
Your commands keep running.
For AI coding agents, tmux is very useful. Put the agent in one pane, tests in another pane, logs in another pane.
Example layout:
+----------------------+----------------------+
| Claude / agent | npm test --watch |
| | |
+----------------------+----------------------+
| dev server logs | git / terminal |
+----------------------+----------------------+
Use zoom often:
Ctrl + b, z
This makes one pane fullscreen temporarily.
Add this to ~/.tmux.conf:
set -g mouse onReload:
tmux source-file ~/.tmux.conftmux lsThen:
tmux attach -t session-nametmux kill-serverBe careful. This closes all tmux sessions.
Some developers change prefix from Ctrl + b to Ctrl + a:
unbind C-b
set -g prefix C-a
bind C-a send-prefixThen use:
Ctrl + a
instead of:
Ctrl + b
Start with only these commands:
Ctrl + b, c new window
Ctrl + b, n next window
Ctrl + b, p previous window
Ctrl + b, % vertical split
Ctrl + b, " horizontal split
Ctrl + b, arrow move pane
Ctrl + b, z zoom pane
Ctrl + b, d detach
That is enough for 90% of daily use.