Quiting ZSH not too quickly
This posts is for zsh shell only.
If you often use command-line tools such as GDB, you certainly know the hotkey ^d (EOF) to quickly quit the CLI. But sometimes, that's too sensitive! If you hit it twice in GDB, you do quit GDB, but also its parent shell!
set -o ignoreeof # 10*^d exits zsh
Okay, we're a bit better now, we won't quit zsh by mistake ... but we cannot close it rapidely on purpose either. So let's improve it: 3 is a better threshold (and zle is zsh line editor):
set -o ignoreeof # 10*^d exits zsh function zle_quit () {exit} zle -N zle-quit zle_quit bindkey "^d^d^d" zle-quit
We simply bind the key sequence ^d^d^d to the quit function! (you have to do it quickly enough, otherwise it won't work)
For emacs fan, this works as well:
bindkey "^x^d" zle-quit