Challenge: write your own tmux.conf
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.
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.
Challenge cleared.
The new server ran every line before creating main, so base-index 1 was in force when its first window was made. bind C-a send-prefix keeps the press-twice habit working on the new key. r now reloads the file without a restart, for everything except base-index on windows that already exist.
Go further
- Past this course:
monitor-activityandmonitor-bellfor alerts, session groups (new-session -t),respawn-pane,pipe-pane,capture-pane,display-menu,wait-for.man tmux, section by section, is the natural next read.
- 1
base-indexonly affects windows made after the server starts, sosourceis not enough. Kill the server and startmainnew. - 2The prefix lines:
set -g prefix C-a,unbind C-b,bind C-a send-prefix. The reload key:bind r source-file ~/.tmux.conf. - 3Once the new server is up, the prefix is
C-a: splitting isC-a |andC-a -. - 4Write the file with
open ~/.tmux.conf, then:kill-serverandtmux new -s main.
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
Alpine Linux and tmux 3.4 on an x86 emulator. Nothing to install, and no server behind it.
about 15 MB, once
Done when
not started- The server restarted (a new pid) and the new prefix is C-a— not done yet
- mouse is on, status-position is top, mode-keys is vi— not done yet
- status-left uses the session_name format— not done yet
- r sources the file, | splits horizontally, - splits vertically— not done yet
- Session main's first window is index 1— not done yet