Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

1 Answer 1

up vote 8 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

Your Answer

 
discard

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.