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
xterm,rxvt,konsole,gnome-terminal, etc.) show the same behavior? – Gilles Jul 7 '11 at 21:00tmux -V) – Torian Aug 18 '11 at 3:55