How can I prevent tmux exiting with Ctrl-d?
To be precise, Ctrld does not exit
tmux, but rather a shell. If that shell is running in the only pane of the last window in the
tmux session, the session ends and the
tmux client exits.
To prevent Ctrld from exiting the shell, you can set the
IGNOREEOF shell variable, or set the
ignoreeof shell option. Put one of the following in your
IGNOREEOF=10 # Shell only exists after the 10th consecutive Ctrl-d set -o ignoreeof # Same as setting IGNOREEOF=10
IGNOREEOF didn't work for me so I just bound Ctrl+D to
detach in .tmux.conf:
bind-key -n C-d detach
-n means no prior escape sequence needed, like the tmux prefix.
Besides chepner's answer you can stop the terminal from sending EOF entirely by setting
stty eof undef
stty eof '^d'