~/.zshrc
is zsh's user configuration for interactive shells. (actually it is $ZDOTDIR/.zshrc
, but HOME
is used if ZDOTDIR
is unset)
~/.zshrc-e
has no special meaning to zsh and is not used by it. Unless, of course, you load it somewhere in ~/.zshrc
. (If I had to guess, I would say it is probably just a backup/copy of ~/.zshrc
, but that is easy to check.)
Zsh does not use the IGNOREEOF
parameter like Bash does. Instead, it is an option that you must set via the setopt
builtin. From zshoptions(1)
:
IGNORE_EOF (-7)
Do not exit on end-of-file. Require the use of exit or logout instead. However, ten consecutive EOFs will cause the shell to exit anyway, to avoid the shell hanging if its tty goes away.
Also, if this option is set and the Zsh Line Editor is used, widgets implemented by shell functions can be bound to EOF (normally Control-D) without printing the normal warning message. This works only for normal widgets, not for completion widgets.
-- The second paragraph is important if you wish to emulate Bash's IGNOREEOF; see below
You can enable this option by adding the following to your shell configuration:
setopt ignore_eof # Option names are case-insensitive and underscores are optional.
Emulating Bash (Optional)
If you would like to emulate the Bash behavior of being able to specify the number of Ctrl+D sequences before exiting the shell, then you can add the following ZLE widget definition* to your configuration:
# Emulate Bash $IGNOREEOF behavior
bash-ctrl-d() {
if [[ $CURSOR == 0 && -z $BUFFER ]]
then
[[ -z $IGNOREEOF || $IGNOREEOF == 0 ]] && exit
if [[ $LASTWIDGET == bash-ctrl-d ]]
then
(( --__BASH_IGNORE_EOF <= 0 )) && exit
else
(( __BASH_IGNORE_EOF = IGNOREEOF-1 ))
fi
zle send-break
else
zle delete-char-or-list
fi
}
Then, add the widget to ZLE and create a keybind for it:
zle -N bash-ctrl-d
bindkey '^D' bash-ctrl-d
You will still need to set the ignore_eof
option however, otherwise Ctrl+D will ignore ZLE and immediately exit the shell regardless of this widget. Refer to the second paragraph of the man page snippet at the beginning of the answer.
* - Credit for this widget goes to its original author, Christoph Lange, and Bart Schaefer for his corrections
Best Answer
That's actually the standard behavior of the dot command: it uses a $PATH search, just like when running commands – not a regular relative path. So you can have your common libraries in e.g. ~/bin/ and simply load them with
. libwhatever.sh
from any directory.Performing a direct relative path lookup is a nonstandard Bash extension.
(Similarly, dot
.
is actually the main command listed in the "shell language" standard, andsource
is a shell-specific alias – not the other way around.)