16

I've decided to try tmux: have been reading the docs and googling around, trying to find a way to have two users sharing a session, each with a different cursor.

However, giving 777 permissions to the socket, or creating a group, chgrping the socket and adding both users to it, seems to let that same socket be used to share a session with only one cursor: both users can write, but always in the same cursor position.

Right now both users are in the same home server over ssh, and the idea is to be able to have:

  • A terminal in a, let's say, left pane, where I can type commands
  • Another terminal in a right pane, where I can see another user typing commands in his own terminal
  • The same thing for the other user

What I'm doing at the moment is using two sessions (not shared) and a script -f and tail -f combination that kinda works for reading each other's key strokes, but I reckon there is probably some way of doing this using tmux sharing capabilities.

Is there a way to get this idea working with write support in each other's terminal?

What is the better way to do this?

  • This should help unix.stackexchange.com/questions/2523/… – clement Apr 2 '14 at 17:57
  • @clement No, that makes two users see the exact same; that is, there is only one cursor, and either both are in the right pane or both are in the left pane. But thanks anyway – ferhtgoldaraz Apr 2 '14 at 18:29
19

This question is a bit old, but I was looking for something similar, and found it here. It creates a second session that shares windows with the first, but has its own view and cursor.

tmux new-session -s alice
tmux new-session -t alice -s bob

If the sharing is happening between two user accounts, you may still have to mess with permissions (which it sounds like you had working already).

Edit: As suggested, a quote from another answer:

First, add a group for tmux users

export TMUX_GROUP=tmux
addgroup $TMUX_GROUP

Create a directory with the group set to $TMUX_GROUP and use the setgid bit so that files created within the directory automatically have the group set to $TMUX_GROUP.

mkdir /var/tmux
chgrp $TMUX_GROUP /var/tmux
chmod g+ws /var/tmux

Next make sure the users that want to share the session are members of $TMUX_GROUP

usermod -aG $TMUX_GROUP user1
usermod -aG $TMUX_GROUP user2
  • Welcome to *nix.SE! This is a pretty good first answer, though I would recommend you consider adding some of the most helpful bits from the second two links in-line (to help avoid link-rot). :) – HalosGhost Jan 19 '15 at 4:00
  • 4
    This allows two users to input to different windows, but not different panes within the same window. (tmux 1.6) – awatts May 9 '17 at 10:48
2

You could try running two separate tmux sessions at once - one for you, and the second for the other user. Then, use your OS's windowing system to arrange two terminals side by side, with one for you and one for him. If you need to write in his terminal, just choose it for input.

You run (each command in its own terminal):

tmux new-session -s Alice
tmux new-session -s Bob

And then Bob runs (again, each command in its own terminal):

tmux attach -t Alice
tmux attach -t Bob

If you do not have a windowing system that supports side-by-side display or you loathe the mouse, you could each (carefully) set this up in an unshared screen/tmux wrapper session.

  • Thanks, but I needed this in a server environment, so no windows (we were messing with how servers work) – ferhtgoldaraz Oct 4 '14 at 19:34
  • 1
    @ferhtgoldaraz: you could just use a split tmux session to contain the two subsessions! – Ashe Nov 27 '14 at 1:56
  • @Yuki: Interesting, I'll look into that – ferhtgoldaraz Nov 27 '14 at 8:25
  • @Ashe What do you mean by split tmux session and two subsessions? Can you elaborate please? – elquimista Jan 10 at 3:16
  • @elquimista hello from over 4 years ago! What I meant was to run tmux, then split the window into two panes (e.g. with ctrl-b % or ctrl-b "), then run tmux (again) in each pane, sharing sessions as suggested in the answer. – Ashe Jan 10 at 4:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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