Answers:
确切地说,Ctrld不退出tmux,而是退出壳。如果该shell在tmux会话中最后一个窗口的唯一窗格中运行,则会话结束,tmux客户端退出。
要防止Ctrld退出shell,可以设置IGNOREEOFshell变量,或设置ignoreeofshell选项。将以下内容之一放入您的.bashrc文件中:
IGNOREEOF=10 # Shell only exists after the 10th consecutive Ctrl-d
set -o ignoreeof # Same as setting IGNOREEOF=10
IGNOREEOF我没有工作,所以我只是必然Ctrl+ D到detach在.tmux.conf:
bind-key -n C-d detach
这-n意味着不需要先前的转义序列,比如tmux前缀。
IGNOREOF因为我使用zsh ,之前没有为我工作。setopt ignoreeof在.zshrc工作中。但我不得不杀死tmux的所有tmux会话来源.zshrc。也许我可以.zshrc从tmux内部采购......
cat > some_new_file.txt。
^D。
bind -n C-d if-shell -b 'USHELL="$(basename "$(getent passwd $USER | cut -d: -f7)")"; [ $(tmux list-windows | wc -l) -eq 1 -a $(tmux list-panes | wc -l) -eq 1 -a $(pstree $PPID | egrep "\\b$USHELL\$" | grep -o $USHELL | wc -l) -eq 1 ]' detach 'send C-d'
exec zshtmux重启zsh当我正在玩
set-environment -g 'IGNOREEOF' 2的.tmux.conf,现在我需要按Ctrl-d 3次退出,我与消息每次还警告说:Use "logout" to leave the shell.