Typically, I use a bash script to create my tmux session (split panes, set PWD, call commands, etc.). This works great, except if I try to run tmux detach-client. It will fail to detach, instead just adds on extra windows and splits everything up weirdly. Not what is expected.

To duplicate: launch a terminal, and run the script. Then create another terminal in another tab (like in gnome-terminal). Run the script again and it will attach as expected. Finally run tmux detach-client, and see the results.

Here is a simpler POC script, and this is the original ones: vimui and tmuxhome.


Problem seems to be just calling tmux detach gets confused about which session. So calling providing the session name works like a charm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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