1

I have configured my Tmux to open with i open terminal by modifying the .zshrc file.

[[ -z "$TMUX" ]] && tmux -u 

It worked fine, now I want to close the tmux session when I close my terminal.

I tried using this:

trap 'tmux kill-session -t "$TMUX_PANE"' EXIT

But it doesn't work.

I am expecting a bash command that would be placed in .zshrc file to close the tmux session along with the terminal.

Thank you in advance.

1
  • 5
    You tagged bash, but mentioned .zshrc; you are expecting "a bash command that would be placed in .zshrc". This file is for zsh, not for bash. What shell do you use inside tmux? What shell do you use outside of tmux? Please edit and do not confuse both shells. If they are both involved somehow then you need to clarify this. Commented Apr 7 at 15:23

1 Answer 1

5

From man 1 tmux:

destroy-unattached [off | on | keep-last | keep-group]

If on, destroy the session after the last client has detached. If off (the default), leave the session orphaned. […]

tmux set-option destroy-unattached on will set the option to on for the current session. If you want tmux always to behave like this, set the global option in your .tmux.conf:

set-option -g destroy-unattached on

and restart your tmux server.

You must log in to answer this question.

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