learntmux.dev
Challenge · no new keys

Challenge: write your own tmux.conf

Goal

A fresh server reads your ~/.tmux.conf, and session main starts at window 1.

Every line you need is one you have already written. The new part is when a line takes effect:

source
changes the running server, but windows that already exist keep the numbers they have
a fresh server
runs the file before anything exists, so every line applies from zero

base-index is the line that exposes the difference: it only affects windows created after it is set. That is why proving this file works takes kill-server and a genuinely new session, not a reload.

Do this

Write ~/.tmux.conf so that a fresh server has all of this:

Requirement Line
Prefix is C-a, and C-a C-a sends it through set -g prefix C-a, unbind C-b, bind C-a send-prefix
Mouse on set -g mouse on
Status line at the top set -g status-position top
Session name on the left of the bar set -g status-left '#{session_name}'
r reloads the file bind r source-file ~/.tmux.conf
| and - split the window bind | split-window -h, bind - split-window -v
Copy mode uses vi keys set -g mode-keys vi
Windows number from 1 set -g base-index 1

Run open ~/.tmux.conf, write the lines from the table, save with Ctrl-S.

Press C-b :, type kill-server, Enter.

You drop to the plain shell.

Run tmux new -s main.

The bar is at the top and reads main; the window list starts at 1.

Press C-a |.

The window splits — and C-b now does nothing.

Stuck on this one?

This is a live terminal. Typing goes to the machine, including Tab. Press Shift and Tab together to move focus back out to the page.

A real terminal, in this tab

about 15 MB, once

session learn

Done when

not started
  1. The server restarted (a new pid) and the new prefix is C-a— not done yet
  2. mouse is on, status-position is top, mode-keys is vi— not done yet
  3. status-left uses the session_name format— not done yet
  4. r sources the file, | splits horizontally, - splits vertically— not done yet
  5. Session main's first window is index 1— not done yet