I am using fish shell. When I type Ctrl-D, it sends a EOF to my terminal and then terminal closes.
I want to make it such that ctrl-D does not close my iterm2.
I saw that people have set up IGNOREEOF in bash shell like this: https://unix.stackexchange.com/questions/27588/how-can-i-keep-controld-from-disconnecting-my-session
However, I don't think this variable exists in fish. Does anybody know how I can force iterm2(with default fish shell) to not close on ctrl-D?
This is the default key binding for control-D:
you can find this by just running
bind
.(
delete-or-exit
is just a function, which you can read withfunctions delete-or-exit
.)So it's exiting because that's what the default behavior is. You can make control-D do something else. For example, maybe it should delete the character under the cursor:
If you want to make this permanent, add it to your
fish_user_key_bindings
function:funced fish_user_key_bindings
which starts editingbind \cd delete-char
within the functionfuncsave fish_user_key_bindings
to save itAfter reading this question and answer I updated my delete-or-exit function to ask for confirmation rather than completely deactivate it:
Then edit/replace:
It has a minor issue in that it displays the prompt twice when you finish, but it seems better than no times if you don't print it (see N case above). Perhaps someone has a solution to that.