Tmux supports creating sessions, and with the -A flag attaching to session if they already exist rather than creating them. But, if they don't exist and tmux has to create them, what's the best way to supply the information needed to initialize them while retaining the ability to simply attach if a session by the same name already exists.

1 Answer 1


The -A flag takes a command argument that only runs if the session is not initialized,

tmux new-session -A -s com "irssi"

For example that will either

  • Attach to a session named com
  • Create a session called com and start up irssi in that session.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .