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 new -t work starts a second session that shares the windows

Tmux
~/tips/tip-tmux-grouped-sessions

tmux new -t work -s work2

Lets two screens look at different windows of the same session.

Two terminals attached to the same session always show the same window. Switch on one and the other follows. A grouped session fixes that.

tmux new -t work -s work2

-t work creates a new session in the same group as work. Both sessions share their windows, so a window you open in one shows up in the other, but each session has its own current window. -s work2 gives the new one a name.

That is how I’d keep logs on a second monitor while the main terminal stays on the editor, all from one set of windows. tmux ls shows the group:

work: 3 windows (created ...) (group work)
work2: 3 windows (created ...) (group work)

Closing a window closes it for every session in the group. Killing work2 leaves the windows alone as long as work still has them.

The extra session tends to stay around after you detach. Setting destroy-unattached on it cleans it up as soon as you detach from it:

tmux new -t work -s work2 \; set destroy-unattached on

If both terminals have different sizes, a shared window takes the size of the client that used it last, so on the smaller screen it may look cut off.

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