Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been using screen for years now as a way of ensuring that any remote work is safely kept open in after disconnects/crashes. In fact, as a matter of course, I use screens even when working locally.

Recently, my requirements have progressed to the stage that I switched to tmux because of the beauty of:

tmux attach -r

Attaching to my own sessions in readonly mode (-r) means that I don't have to worry about accidentally:

  • pasting lines of garbage in IRC
  • halting an important compile/deploy process
  • typing a password in full view for passersby

Of course the issue is that I have to open a session, C-b + d to detach, and then reopen it with the -r flag to go readonly. And then, when I occasionally want to chime in to an IRC conversation, interrupt a task or anything else, I have to detach again and reconnect normally.

Does anyone know of a way to make a key binding to switch between modes?

share|improve this question
up vote 10 down vote accepted

Not according to the man page, which only calls out the attach -r option to enable read-only mode.

Also, in the source code, only the following line in cmd-attach-session.c sets the read only flag. The rest of the code checks whether this flag is set, but does not change its value. So again, it looks like you are out of luck unless you can make (or request) a code change:

    if (cmd_check_flag(data->chflags, 'r'))
        ctx->cmdclient->flags |= CLIENT_READONLY;
share|improve this answer
Thanks for going so in-depth. It has been a while since I've developed in any flavour of C/C++ but I guess I can put it in my 'someday' pile. In the meantime, it won't hurt to put a feature request in so I'm off to do that now. – connrs Feb 18 '11 at 9:31

In tmux 1.9a you can do :switch-client -r. I'm not sure if this is new in 1.9a, but that is the version that I am running and I am able to change an existing tmux session to read-only mode.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.