Note that I use byobu to front end things, and when using screen this can easily be done. I have seen workarounds that involve using multiple copies of tmux talking to each other in various heroic configurations but that is silly.
Note that I use byobu to front end things, and when using screen this can easily be done. I have seen workarounds that involve using multiple copies of tmux talking to each other in various heroic configurations but that is silly.
From the manpage (for new-session): If -t is given, the new session is grouped with target-session. This means they share the same set of windows - all windows from target-session are linked to the new session and any subsequent new windows or windows being closed are applied to both sessions. The current and previous window and any session options remain independent and either session may be killed without affecting the other.
Instead of running tmux directly, I have a small script which creates a session named TMUX-MASTER if it doesn't already exist, and immediately detaches it. All the clients that I actually interact with are created separately and automatically grouped with the TMUX-MASTER session.
To prevent my system from being clogged by dozens of detached client sessions, I rebound prefix+d to kill-session, killing the client session but leaving my TMUX-MASTER session untouched. Closing terminals while running these client sessions, however, still leaves my system cluttered with dormant client sessions.
I'd like to see if a "ephemeral" option (it'd need a better name) could easily be added to new-session, which would cause the created session to just die when it's told to detach, or receives the HUP signal. It'd simplify things a bit.
First, terminology. I know that tmux has: servers, clients, windows, sessions, and panes, but I've never bothered to understand how they fit together.
* server - The server is a process that listens on a unix socket, and accepts connections from clients. Each server manages one or more sessions, which is a grouping of windows.
* client - A terminal connected to the server. Each client connects to a single session on the server.
* session - A collection of windows on a server.
Each session has a single 'active window.' When you connect two clients to a single session, switching the current active window affects what both clients see.
Solution:
Windows can be shared between sessions, and a single window can be present in multiple sessions. This culminates in a tmux feature called "grouped sessions" where multiple sessions are linked and share the same windows. You can use this command:
tmux new-session -t session-id
source: http://unix.stackexchange.com/questions/24274/attach-to-diff...I'm glad you raised this issue because I've only recently moved to tmux and would have been stung by it.
Could you abstract it away behind a shell alias? I used this:
alias tmuxc='tmux new-session -t 0'You could petition for an option to the `attach-session` command that automatically creates a new session grouped to the session that you're 'attaching' to. IIRC, you can't attach two 'clients' to the same (GNU) screen session unless you use the -x option, so it's not like it's the 'default' behaviour for screen either.
Edit:
I wasn't thinking, but `new-session` will automatically connect to the new session you created, so there is no need for an option to `attach-session`. So when you want to connect a second client, just:
# find the session you want
$ tmux list-sessions
# create a grouped session
$ tmux new-session -t SESSION_ID
Edit 2: | This is so much more complicated!
Depends. If you're using byobu, then you're already attempting to abstract away a bunch of the complexity of GNU screen, so it's not like you would find less complexity if you dove into the screen internals. It's also this design that makes it easier to do complex things that screen can't do with its windows. | When using byobu I use F3 and F4 to cycle to
| previous and next window.
Maybe you're misunderstanding. You still use the same tmux bindings to switch windows, it's just the setting up of the session that requires slightly more work when connecting a second client.I did switch it from screen to tmux because tmux definitely works better for other things and seems more responsive when there is lots of output. By default screen did let each client view independent of any other.
I don't see how to automate getting the behaviour I want (independent client views) as typing commands and feeding them into tmux would be a huge pain (especially as byobu is already doing that).
$ tmux.sh session-name
which would create the session the first time, and create a grouped session, the second time.Edit:
I've created a little script for this: https://github.com/bsandrow/tmux.sh