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 attach -r lets someone watch a session without typing in it

Tmux
~/tips/tip-tmux-attach-read-only

tmux attach -r -t demo

Attaches a client that can see a session but not change it.

When I want to show something running in tmux, or keep an eye on a session from a second screen, I don’t want stray keystrokes to land in it.

tmux attach -r -t demo

-r attaches read-only. You see everything that happens in the session demo, but your keys are ignored, except for the ones bound to detach-client and switch-client. So Ctrl-b d still gets you out.

On recent versions -r is shorthand for -f read-only,ignore-size. The ignore-size part means a watching client with a small window doesn’t shrink the session for the person working in it.

You can also flip it while attached, with switch-client -r from the command prompt. It toggles the read-only flag on your own client.

Read-only is a property of the client, not a security boundary. Anyone who can reach the tmux socket can attach again without -r. For sharing with another user account, tmux 3.3 and later have server-access, which can force a user to read-only.

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