You can move between tmux panes and resize them using just your keyboard, and it’s way faster than fiddling with the mouse.
Here’s a quick look at it in action. Imagine you’ve got a few panes open:
# Start up tmux and split the window vertically
tmux new-session -d
tmux split-window -h
# Now, let's split the right pane horizontally
tmux split-window -v
# You should have 3 panes. Let's add a 4th to the top-right
tmux select-pane -t 0 # Select the top-left pane
tmux split-window -v
tmux select-pane -t 2 # Select the new bottom-right pane
tmux split-window -h
Now, if you run tmux attach, you’ll see something like this (the pane numbers are just for reference here):
+---+---+
| 0 | 1 |
+---+---+
| 2 | 3 |
+---+---+
To navigate, you’ll use a prefix key (usually Ctrl+b by default) followed by a direction key.
Moving Between Panes
Your prefix key (Ctrl+b by default) followed by an arrow key will move you to the adjacent pane in that direction.
Ctrl+b←: Move to the pane on the left.Ctrl+b→: Move to the pane on the right.Ctrl+b↑: Move to the pane above.Ctrl+b↓: Move to the pane below.
You can also use Ctrl+b o to cycle through panes in the order they were created. It’s a bit like a tab-switching for your windows.
Resizing Panes
Resizing is similar, but you add Ctrl to the prefix key combination.
Ctrl+bCtrl+←: Shrink the current pane to the left.Ctrl+bCtrl+→: Expand the current pane to the right.Ctrl+bCtrl+↑: Shrink the current pane upwards.Ctrl+bCtrl+↓: Expand the current pane downwards.
The amount you resize by default is usually 1 cell at a time. This can be tedious if you need to make big changes. You can adjust this with the window-size option.
Controlling Resize Granularity
The window-size option in your .tmux.conf controls how many cells are affected by each resize command.
To make resizing more granular (e.g., 5 cells at a time):
set-option -g window-size 5
To make it less granular (e.g., 1 cell at a time, which is the default):
set-option -g window-size 1
If you want to resize in larger, fixed increments, you can bind custom keys. For example, to resize by 10 cells:
bind-key -r -T pane-resizing ↑ { resize-pane -U 10 }
bind-key -r -T pane-resizing ↓ { resize-pane -D 10 }
bind-key -r -T pane-resizing ← { resize-pane -L 10 }
bind-key -r -T pane-resizing → { resize-pane -R 10 }
The -r flag means the key will repeat if held down. The -T pane-resizing specifies that these bindings only apply when you are in the pane resizing mode, which is automatically entered when you use the Ctrl+b Ctrl+<arrow> combination.
Switching Pane Borders
Sometimes, you want to quickly see the borders of your panes to understand their layout. You can toggle these borders on and off:
Ctrl+bq: This command will briefly show the pane numbers. Holding it down will keep them visible.
This is incredibly useful when you have many panes open and forget which number corresponds to which.
The window-size option isn’t just about how much you resize by; it also affects how tmux calculates pane sizes when you create new windows or sessions. By default, tmux tries to make panes as equal as possible. If you have a very wide screen and split it vertically, you might get two panes that are almost square. Setting window-size to largest can sometimes help tmux make better decisions about initial pane sizing, but it’s often more about the per-command resizing granularity.
Once you’ve mastered these pane navigation and resizing commands, you’ll find yourself working much more efficiently within your terminal sessions. The next step is often about managing multiple windows within a single tmux session.