TMUX Shared Session – Different Cursors for Different Users

consolesshterminalterminal-multiplexertmux

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?

Best Answer

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
Related Question