Use “Grouped Sessions”
Instead of attaching to a session, you can create a “grouped session” by giving
tmux new-session -t 'original session name or number'
Sessions that are grouped always have the same windows (new (closed) windows are linked into (removed from) all the session in the group), but they each have their own session options, including the current and previous window values.
If you and your friend each work in a session that is part of the the same group, then you can each work in different windows but still have easy access to the same set of windows, or even work in the same window (if that is appropriate).
Create an initial session:
tmux # start initial session, lets say it gets the name '3'
To keep it clear who should use each session, you should will probably want to give each session a mnemonic name. I will use
mine below, but you will probably want to use something based on your real names, nick names, login names, or something else equally identifying.
Rename this original session as
his and (outside of the original session) create a grouped session named
tmux rename-session -t 3 his
tmux new-session -d -t his -s mine # leave off -d to attach right away
When you want to attach to your clone of “the session”:
tmux attach-sesssion -t mine
When your friend wants to attach to his clone of “the session”:
tmux attach-session -t his
kill-session either session and the other will survive. You have to kill all of the sessions in a group before their windows will be forcibly closed.
tmux Command Abbreviations
If you are scripting the tmux commands, it is probably best to use the full command names (as above) to avoid ambiguity and aid in “self documentation”. If you are typing them you can use abbreviations: