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 -L test starts a second, separate tmux server

Tmux
~/tips/tip-tmux-socket-name

tmux -L test -f /tmp/test.conf new -s try

Runs an independent tmux server on a named socket, separate from your normal sessions.

When I want to try a config change without risking my running sessions, a second tmux server is the safest way to do it. It takes one flag.

The manual says tmux stores the server socket in a directory under TMUX_TMPDIR, or /tmp if that is unset, and that the default socket is named default. The -L flag picks another name:

tmux -L test -f /tmp/test.conf new -s try

That allows several independent tmux servers to run. Here -f makes the new server read a different config file, so your real ~/.tmux.conf stays untouched. Sessions on the test server do not show up in your normal tmux ls.

To list or attach to them later, repeat the flag:

tmux -L test ls
tmux -L test attach

The config file is only read when the server starts. The manual says tmux loads configuration files once when the server process has started, so -f does nothing if a server with that socket name is already running. Stop the test server first, then start it again with the new file:

tmux -L test kill-server

That ends only the server on the test socket, and your normal sessions keep running.

The caveat: every tmux command needs the same -L, or it talks to the default server and says there is nothing running. Keep that in mind when scripting. The -S flag takes a full path to a socket instead of a name, and when it is given, -L is ignored.

Further reading: tmux manual (-L socket-name)

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