The tmux attach command acts more like a combination of screen -r and screen -x -- first it trys to attach to the most recently detached session, and then if none is available it will attach to a currently attached session. I want to emulate the behavior of screen -R: first try to attach to a detached session, then start a new session if there were no detached sessions. What is the best way to achieve this in tmux?
|
|
|||
|
|
|
After consulting the wizards of IRC I am confident there is no single tmux command that has this behavior. Luckily, it is fairly easy to emulate using the shell:
|
|||
|
|
|
Despite what it says in tmux manual:
Drew's answer won't work properly in a situation like:
Another approach would be to manually select a non-attached session:
|
|||||
|
|
I tend to only have two tmux sessions at a time, so I do something like this in each terminal window. terminal window 0:
terminal window 1:
|
||||
|
|
|
What about
or instead just create the file
to it such that it creates a new session when there is none when you run It might also be handy to make |
|||
|