Issue
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?
Solution
This is the default key binding for control-D:
bind \cd delete-or-exit
you can find this by just running bind
.
(delete-or-exit
is just a function, which you can read with functions 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:
bind \cd delete-char
If you want to make this permanent, add it to your fish_user_key_bindings
function:
- Run
funced fish_user_key_bindings
which starts editing - Put
bind \cd delete-char
within the function - Hit return to create the function
- Run
funcsave fish_user_key_bindings
to save it
Answered By - ridiculous_fish Answer Checked By - Katrina (WPSolving Volunteer)