I'm using tmux on a Fedora 8 server (workplace restriction) to monitor several boxes on a stress rack. I noticed that I can only attach to my detached tmux session once per shell session. In order to reattach, I must kill the terminal session and start another one, otherwise my attach command simply hangs (although, Ctrl-b,d detaches from the hung command).

Has anyone seen behavior like this before? Any guidance or pointers to references would be greatly appreciated.

  • 2
    What terminal emulator is this? Do other terminal emulators (xterm, rxvt, konsole, gnome-terminal, etc.) show the same behavior? – Gilles Jul 7 '11 at 21:00
  • 1
    what tmux version are you running ? (tmux -V) – Torian Aug 18 '11 at 3:55

In my Shell's config file (I use zsh, so its in my .zshrc, should work in a .bashrc) I have the following:

# Default to TMUX
if [ -z "$TMUX" ]; then
  # Create the base session if it doesn't exist
  tmux has-session -t $base_session || tmux new-session -d -s $base_session
  # Get a count of clients connected
  client_cnt=$(tmux list-clients | wc -l)
  if [ $client_cnt -ge 1 ]; then
    # Make a unique session name
    # Create the new session based on the base_session
    tmux new-session -d -t $base_session -s $session_name
    # Launch the connection with a few caveats (kill the session when the client goes away)
    tmux -2 attach-session -t $session_name \; set-option destroy-unattached
    tmux -2 attach-session -t $base_session

Now I can connect many times using PuTTY to a single server and see the same session in all windows (and change one connection to display a different window). I would also like to


I thought this was working once before, then I just learned that I must have still been in screen, so I have fixed this to do separate sessions. I commented, so let me know if you have any questions. Now there is one downside to this, it will choose the smallest size for both windows. That isn't helpful...I am working on finding a fix currently.

Edit 2

In order to fix the resizing issue, add the following line to your .tmux.conf file

set-option -g aggressive-resize on

It is perhaps a version problem. You can reattach a session, but you won't be able to view different windows as you would with screen.

To reattach to a session:

$ tmux attach -t <session-name>

You can try attaching to the session explicitly dropping any other connections:

tmux a -d

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.