Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

IGNORE_EOF like in bash

Hi there,

  last year I suggested that the IGNORE_EOF shell option should be
implemented the same way as in bash, which means that the user can determine
how many consecutive presses of ^D are ignored before he or she is logged

This has not been done by now, but I found out that one can script it in
zsh-4.0.1-pre-3 (maybe in other versions later than zsh-3.1.9, too), since
the shell no longer bypasses ZLE when ^D is pressed on an empty command

Here is my solution, configurable by the variable IGNOREEOF:

IGNOREEOF=3				# or something like that

bash-ctrl-d() {
  if [[ $CURSOR == 0 && -z $BUFFER ]]
    [[ -z $IGNOREEOF || $IGNOREEOF == 0 ]] && exit
    [[ $LASTWIDGET == bash-ctrl-d ]] \
      && (( --__BASH_IGNORE_EOF == 0 )) \
      && exit
    zle send-break
    zle delete-char-or-list

zle -N bash-ctrl-d
bindkey "^D" bash-ctrl-d

Hope you find it useful,


Geeks aren't interested in politics because government doesn't
double its efficiency and speed once every 18 months.
Christoph Lange, langec@xxxxxx, http://www.cul.de/home/yaph/, ICQ #51191833

Messages sorted by: Reverse Date, Date, Thread, Author