tmux: create session if none exists

Posted by rampion on Stack Overflow See other posts from Stack Overflow or by rampion
Published on 2010-08-07T23:58:03Z Indexed on 2011/01/17 20:53 UTC
Read the original article Hit count: 148

Filed under:

I'm switching from using gnu-screen to tmux, and I'm still trying to wrap my head around changes.

One thing I'd like to be able to do is start tmux and have it automatically connect to a session if one exists, and otherwise create a new session.

  • tmux attach attaches to an automatically existing session - but errors out if no session exists
  • tmux new creates a new session - but it does so every time, so I can't leave it in my .tmux.conf
  • tmux has-session tests whether a session exists - but I don't know how to stitch it together with the other commands

Can anyone give me some configure file advice?

© Stack Overflow or respective owner

Related posts about tmux