learntmux.dev

Write the configuration file

Goal

~/.tmux.conf sets mouse on, and a fresh server starts with it on, unsourced.

~/.tmux.conf is a list of tmux commands, one per line, run when the server starts. # starts a comment.

the file
runs once, at server start
source ~/.tmux.conf at C-b :
runs it against the server already running, so you can test without restarting

That distinction is the whole lesson. Starting a new session inside a running server does not re-read the file. And anything you set by hand disappears when the server exits, while anything in the file comes back every single start.

Do this

Run echo '# turn on mouse support' >> ~/.tmux.conf, then echo 'set -g mouse on' >> ~/.tmux.conf.

Two lines now sit in the file. >> appends; > would overwrite it.

Press C-b :, type source ~/.tmux.conf, Enter.

tmux show -g mouse now prints mouse on.

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

You drop to the plain shell, and the hand-set option goes with the server.

Run tmux new -s learn.

The new server read the file first: tmux show -g mouse prints mouse on with no sourcing.

How the configuration file is parsed

It is not a shell script. ~ and quotes work; $() does not.

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. ~/.tmux.conf contains the set -g mouse on line— not done yet
  2. The running server has mouse set to on after sourcing the file— not done yet
  3. The old server no longer answers— not done yet
  4. A different server is running and it read the configuration file at start— not done yet