Nicholas Clooney

Tmux 70/20/10 Layout Shortcuts

I wanted a small tmux workflow improvement: create a repeatable 70/20/10 vertical layout in one keystroke, then swap the top 70% pane with the middle 20% pane without disturbing the overall proportions.

The Initial Attempt

The initial research, generated by Claude, was directionally right but flawed in implementation detail. The recommendation to use swap-pane -s 0 -t 1 was fine, and the suggested layout math for split-window -v -p 30 followed by split-window -v -p 33 was also fine. The problem was treating the layout binding as a straightforward grouped tmux command and assuming a simple if-shell wrapper would reliably execute the whole sequence. In practice, the config loaded, but the grouped split commands did not execute correctly from the binding.

The Fix

The fix was to stop relying on brittle grouped-command parsing inside tmux bindings and instead move the logic into run-shell guards. The final implementation checks whether the current window has exactly one pane before creating the layout, captures the current pane path so new panes inherit it, performs the two vertical splits, re-selects the top pane, and tags the window with a custom option: @stack702010=1. The swap binding also uses run-shell, and only runs when that tag is present and the window still has exactly three panes. That keeps the shortcut scoped to the intended layout instead of affecting arbitrary three-pane windows.

How I Tested It

The way I got there matters. Rather than repeatedly editing ~/.tmux.conf and testing manually in the live session, I used tmux itself as a lightweight TDD harness. First, I inspected the parsed binding with tmux list-keys to confirm that tmux had accepted the binding text. Then I created detached test sessions with tmux new-session -d, ran candidate commands against those sessions, and verified the result with tmux list-panes and tmux show-options.

That made it obvious that the original if-shell form was loading but not executing the full split sequence correctly, while the run-shell version produced the expected three panes and correctly set @stack702010=1. Only after that detached-session test passed did I patch the real config. For this kind of tmux customization, it is a strong workflow: treat tmux as something you can probe and assert against, not just something you manually poke at through the UI.

Shortcut Ergonomics

The human-driven refinement was ergonomic rather than architectural. The original working shortcuts used prefix + L and prefix + S, which required changing modifier posture mid-sequence. That was updated to prefix, Ctrl+L for layout creation and prefix, Ctrl+S for swapping panes so the whole interaction stays on control-key chords after Ctrl+B.

That change made the shortcut sequence more comfortable, with one caveat: Ctrl+S can conflict with terminal flow control in some environments.

Current Config

Current behavior in ~/.tmux.conf:

bind C-l run-shell 'if [ "$(tmux display-message -p "#{window_panes}")" = "1" ]; then path="$(tmux display-message -p "#{pane_current_path}")"; tmux split-window -v -p 30 -c "$path"; tmux split-window -v -p 33 -c "$path"; tmux select-pane -t 0; tmux set-option -w @stack702010 1; else tmux display-message "70/20/10 layout requires a single-pane window"; fi'

bind C-s run-shell 'if [ "$(tmux display-message -p "#{@stack702010}")" = "1" ] && [ "$(tmux display-message -p "#{window_panes}")" = "3" ]; then tmux swap-pane -s 0 -t 1; else tmux display-message "Current window is not the 70/20/10 layout"; fi'

Why It Works

The result is a small but robust tmux customization: deterministic layout creation, scoped pane swapping, and shortcuts that are comfortable enough to use repeatedly.