19

I've recently converted from gnu-screen to tmux. I am struggling with 1 thing.

My workflow is something like this. I create a session for each "task" I am doing at any point in time. That way I can work on any of the N tasks I am doing by attaching to that session.

What I was able to do with screen and not being able to do with tmux is following: Having multiple instances of the same session open/attached in different windows and working on them at the same time. For example, if I am editing 3 different files, I can have them open in pane1, 2 and 3 of the same session and have each instance of the same session with those 3 files open in front of me.

I've not been able to arm-twist tmux into letting me do that. Whenever I attach to an existing attached session in tmux, it replicates the actions I take on any session on the other.

I hope I've explained this well. If not, please let me know.

2 Answers 2

21

I think you're basically asking how to do screen -x in tmux? Here's an example:

# Start a new tmux session (with default session name "0").
tmux

# Start another tmux session (default name "1"), sharing windows with "0".
tmux new-session -t 0

# Start yet another tmux session (default name "2"), sharing windows with "0" (and "1").
tmux new-session -t 0

# Now you can attach to sessions with tmux attach-session -t <0|1|2>.
# Or you can omit the -t, and tmux needs to select the most recently used session, and it will prefer the most recently used unattached session.

If you don't like the default numerical names when creating a new session, you can pass -s other_name to name it something else.

1
  • The key word to search for here is session group.
    – Kaligule
    Feb 9, 2022 at 9:22
1

To achieve what you describe you might get away with just having different layouts in tmux (C-b + c) which you then split using (C-b +) % and ", you can just have all the things you want for a task in a pane and then context switch using C-b +n(ext) or p(revious) or using numbers. Also C-b z(oom) is your friend.

Interestingly tmux and screen are different in how they deal with multiple views of the same session

  • in tmux both views see exactly the same thing (which lets you do pair programming remotely)
  • in screen you can look at different terminals in different views (which lets you share things but work independently... which is possibly useful for using multiple monitors to work on the same command line, I just haven't figured out exactly how yet!)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .