6

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.

5

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 I think it attaches to one that isn't attached to yet.
# I don't know the exact rules for how it decides which free session to choose.

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.

0

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!)

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.