2

I am starting a process in a tmux window in a terminal window. When I close the terminal window, the process not killing automatically but If I kill tmux window before close terminal window, the process killing. How can I kill related tmux window when the terminal window closed ?

Can we bind commands the close event of the terminal window ?

2

This is a bit of a hack but you could add this to your interactive shell configuration:

alias tmuxn='tmux new-session -s $$'
_trap_exit() { tmux kill-session -t $$; }
trap _trap_exit EXIT

Then you can use tmuxn to start a new session. The session will be named as your shell's PID. When your shell exits, the session will be killed.

1

Maybe you can not.
For most people who use tmux, they usually close the terminal window instead of the tmux window in order to keep the process (ssh-client for example) running. And then, you can attach the origin tmux session in another terminal.
If you do not need this feature, you can use terminator instead of tmux. Terminator splits the terminal window itself. So, if you close the terminator window, you close everything running in that window. Nothing will be kept in the background.

  • I love tmux. I am opening tmux windows in a terminal window for related processes(more than one tmux window) and opening another terminal window for other works. So I am working with more than one terminal window at a time. Ok, than I will kill tmux windows or detach client before close terminal window. – Mesut Tasci Jul 23 '13 at 2:17

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.