Session groups one or more windows together.
Each session has one current window, this is the window displayed when the session is attached and is the default window for any commands that target the session. Sessions do not have an index but they do have a name, which must be unique.
Every window has a name – by default tmux will choose one but it can be changed by the user. Multiple windows are grouped together into sessions. If a window is part of a session, it is said to be linked to that session.
Windows may be linked to multiple sessions at the same time, although mostly they are only in one. Each window in a session has a number, called the window index – the same window may be linked at different indexes in different sessions.
- List existing sessions
- Create a new session with name and without name
tmux new -s name
- Attache to an existing session or most recently used sessions
tmux attach -t name
- Rename session (within a session)
- Detach the currently attached session
- Switch session (within a session)
tmux switch -t name
- Kill a session by name:
tmux kill-session -t name
The status line
When a tmux client is attached, it shows a status line on the bottom line of the screen.
As new windows are opened, the window list grows – if there are too many windows to fit on the width of the terminal, a
> will be added at the left or right or both to show there are hidden windows.
In the window list, the current window is marked with a
* after the name, and the last window with a
A window groups one or more panes together, linked to one or more sessions.
- Create a new window
- Change to a window using index
tmux select-window -t :0-9
C-b 0changes to window 0
C-b 1to window 1, up to
C-b 9for window 9.
- Change to next window in the window list by number.
- Change to previous window int he window list by number
- Rename the current window
- Choose a window from the list
A pane contains a terminal and running program, appears in one window
Splitting the window
A pane is created by splitting a window.
This is done with the
split-window command which is bound to two keys by default:
C-b %splits the current pane into two horizontally, producing two panes next to each other, one on the left and one on the right.
tmux split-window -h
C-b "splits the current pane into two vertically, producing two panes one above the other.
Each time a pane is split into two, each of those panes may be split again using the same key bindings, until the pane becomes too small.
Changing the active pane
The active pane can be changed between the panes in a window with these key bindings:
- Change to the pane above, below, left or right of the active pane
tmux select-pane -[UDLR]
These keys wrap around the window, so pressing
Ctrl-b Downon a pane at the bottom will change to a pane at the top.
- Move to the next pane by pane number
- Selects the next pane in numerical order
tmux select-pane -t :.+
- Print the pane numbers and their sizes on top of the panes for a short time
Ctrl-b q 0will change to pane number 0
Ctrl-b q 1will change to pane number 1
- Swaps pane with another in the specified direction
tmux swap-pane -[UDLR]
- Swaps that pane with the active pane, so they exchange positions and sizes in the window.
Pane numbers are not fixed, instead panes are numbered by their position in the window, so if the pane with number
0 is swapped with the pane with number
1, the numbers are swapped as well as the panes themselves.
Helpful tmux commands
- Every default tmux key binding has a short description to help remember what the key does.
tmux list-keys -N | less
- List out every bound key and the tmux command it runs
- List out every session, window, pane, its pid, etc.
- Reload the current tmux configuration (based on a default tmux config)
tmux source-file ~/.tmux.conf