brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: tmux source-file -n checks your config for errors without applying it

Tmux
~/tips/tip-tmux-source-file-check

tmux source-file -n ~/.tmux.conf

Finds typos in a tmux config before you load it.

A typo in ~/.tmux.conf shows up as an error the next time the server starts, which is the wrong moment to find it. You can test the file first.

tmux source-file -n ~/.tmux.conf

With -n, tmux parses the file but runs none of the commands. If it finds a problem it prints the file name, the line number and what is wrong, and the exit status is 1. A clean file prints nothing and returns 0.

A test file with a made up command gives something like this:

/home/me/.tmux.conf:2: unknown command: foo-bar

Add -v to also see each parsed command with its line number. Because of the exit status it fits nicely in a reload binding or a script, so that a broken file never gets sourced:

tmux source-file -n ~/.tmux.conf && tmux source-file ~/.tmux.conf

It is a parse check, not a full test. Wrong option values or a binding to something that fails at run time can still pass. Like most tmux commands it talks to the running server, so I’d run it from inside a tmux pane.

Further reading: tmux manual page (OpenBSD)

More Tmux tips tmux new -d -s report -x 200 -y 50 'top' tmux wait-for build-done set -g allow-passthrough on tmux kill-server Ctrl-b [ All Tmux tips (125) All topics

Link