Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
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
add comment

3 Answers

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
  base_session=$USER"_session"
  # 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
    session_name=$base_session"-"$client_cnt
    # 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
  else
    tmux -2 attach-session -t $base_session
  fi
fi

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

Edit

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
share|improve this answer
add comment

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>
share|improve this answer
add comment

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

tmux a -d
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.