1

I have set my zsh auto start a tmux session when there is no one, like this

 if [[ ! $TERM =~ screen ]]; then
    exec tmux
 fi

Yeah, this works fine, however when I detach the session, the terminal(I am using gnome-shell) will exit too. How do I avoid it

  • You could use tmux instead of exec, but that just raises the question of why you are using exec in the first place. – chepner May 23 '17 at 1:19
  • @chepner Thanks, it works as I want now, after change 'exec tmux' to 'tmux'. in fact I don't known the difference between tmux and exec tmux, I just copy from somewhere in this site. – fangxing May 23 '17 at 1:39
0

Thanks for @chepner's comment, I just need to change exec tmux to tmux, because exec executes a specified command, replacing the current process rather than starting a new subprocess.

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.