tmux: shared session, one user in a pane, another in another pane, two different cursors

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?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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

Method 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.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x