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

9,736

Solution 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

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

Share:
9,736

Related videos on Youtube

ferhtgoldaraz
Author by

ferhtgoldaraz

Updated on September 18, 2022

Comments

  • ferhtgoldaraz
    ferhtgoldaraz over 1 year

    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?

    • Admin
      Admin about 10 years
    • Admin
      Admin about 10 years
      @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
    ferhtgoldaraz over 9 years
    Thanks, but I needed this in a server environment, so no windows (we were messing with how servers work)
  • Asherah
    Asherah over 9 years
    @ferhtgoldaraz: you could just use a split tmux session to contain the two subsessions!
  • ferhtgoldaraz
    ferhtgoldaraz over 9 years
    @Yuki: Interesting, I'll look into that
  • Jakob Bennemann
    Jakob Bennemann over 9 years
    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). :)
  • awatts
    awatts almost 7 years
    This allows two users to input to different windows, but not different panes within the same window. (tmux 1.6)
  • elquimista
    elquimista over 5 years
    @Ashe What do you mean by split tmux session and two subsessions? Can you elaborate please?
  • Asherah
    Asherah over 5 years
    @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.
  • elquimista
    elquimista over 5 years
    @Ashe that is actually misleading 'cuz people will attach to completely different sessions (which you call it 'subsession') and this defeats the original purpose of session sharing, i.e. people can't see each other what other person is doing, can they?
  • Asherah
    Asherah over 5 years
    @elquimista I think you misunderstand me. Refer to the answer for how to ensure the sessions are shared. The split session is just a way to put two other tmux (shared) sessions side-by-side without using a window manager.