Skip to main content

Layouts and Tiling

Tmux includes five built-in layout presets and lets you create custom arrangements. Understanding layouts turns tmux from a session tool into a full workspace manager.

Learning Focus

Learn the five built-in layouts and how to lock in a custom layout using a scripted setup.

The Five Built-In Layouts

Cycle through layouts with:

Ctrl+b Space      → Cycle through next layout preset

Or apply a specific one via command prompt:

:select-layout even-horizontal
:select-layout even-vertical
:select-layout main-horizontal
:select-layout main-vertical
:select-layout tiled

1. even-horizontal — Side by Side

┌──────┬──────┬──────┐
│ │ │ │
│ p1 │ p2 │ p3 │
│ │ │ │
└──────┴──────┴──────┘

All panes share equal width, stacked horizontally.

2. even-vertical — Stacked

┌──────────────────────┐
│ p1 │
├──────────────────────┤
│ p2 │
├──────────────────────┤
│ p3 │
└──────────────────────┘

All panes share equal height, stacked vertically.

3. main-horizontal — One Large Top

┌──────────────────────┐
│ │
│ main │
│ │
├──────┬──────┬────────┤
│ p2 │ p3 │ p4 │
└──────┴──────┴────────┘

Large primary pane on top, smaller panes below.

4. main-vertical — One Large Left

┌──────────┬─────────┐
│ │ p2 │
│ main ├─────────┤
│ │ p3 │
│ ├─────────┤
│ │ p4 │
└──────────┴─────────┘

Large primary pane on the left, smaller panes on the right.

5. tiled — Grid

┌──────────┬──────────┐
│ p1 │ p2 │
├──────────┼──────────┤
│ p3 │ p4 │
└──────────┴──────────┘

All panes arranged in a balanced grid.

Setting Main Pane Size

# Control the main pane width (main-vertical layout)
:set-window-option main-pane-width 120

# Control the main pane height (main-horizontal layout)
:set-window-option main-pane-height 30

Add to ~/.tmux.conf to make it permanent:

~/.tmux.conf
set -g main-pane-width 120
set -g main-pane-height 30

Custom Scripted Layout

Build a specific layout with splits and commands:

monitoring-layout.sh
#!/bin/bash
SESSION="monitoring"

tmux new -s "$SESSION" -d -n "dashboard"

# Split into 4 panes: 2x2 grid
tmux split-window -h -t "$SESSION:dashboard"
tmux split-window -v -t "$SESSION:dashboard.0"
tmux split-window -v -t "$SESSION:dashboard.1"

# Send commands to each pane
tmux send-keys -t "$SESSION:dashboard.0" "htop" Enter
tmux send-keys -t "$SESSION:dashboard.1" "tail -f /var/log/syslog" Enter
tmux send-keys -t "$SESSION:dashboard.2" "df -h && watch df -h" Enter
tmux send-keys -t "$SESSION:dashboard.3" "netstat -tuln" Enter

# Apply tiled layout
tmux select-layout -t "$SESSION:dashboard" tiled

# Attach
tmux attach -t "$SESSION"

Saving and Restoring Layouts

Tmux does not natively save pane layouts across sessions, but you can:

  1. Use a script — write a shell script that rebuilds your layout.
  2. Use a plugintmux-resurrect or tmux-continuum saves/restores sessions automatically (see Plugins module).

Quick Layout Reference

PresetBest for
even-horizontalMultiple side-by-side log watchers
even-verticalSequential command output
main-horizontalEditor with multiple small monitors below
main-verticalEditor with sidebar monitors
tiledDashboard with equal monitoring panels

What's Next