Deactivate Shortcut Control D

Is there a quick convenient way to disable the shortcut Control D (used to quit)?

I believe (not that certain) interrupting the repl with eof i.e. Ctrl+D is baked into it so unless there is an option to specifically disable it, it cannot be done. Shells support disabling it.

1 Like

Okay. Thanks.

Would be nice to have it.

Ctrl+D as EOF is implemented in your TTY driver, and can be manipulated from the commandline with the stty POSIX command. Specifically, you could remap it to some other Ctrl+Key command that doesn’t negatively interact with your workflow.

1 Like

You can customize the keybindings, see this manual section.

For example, to do nothing on CTRL+D you can put this in your startup file:

import REPL
mykeys = Dict{Any,Any}("^D" => (s, o...) -> nothing)
function customize_keys(repl)
    repl.interface = REPL.setup_interface(repl; extra_repl_keymap = mykeys)
end
atreplinit(customize_keys)
4 Likes

Thanks, both of you. I will see if it’ll work out.

Edit: yes, I used the manual and your example code to construct a piece of code (combination), and it works.

Depending on your reasons to de-activate Control-D, you migtht be interested in the possibility for being asked for confirmation before exiting: if you type Controlr-D when this would normally quit, you will get this message:

julia> Type ^D again to exit.

julia>

To activate this as yet undocumented feature, you can do repl.options.confirm_exit = true in a atreplinit function like above, or interactively at the REPL by replacing repl by Base.active_repl.

5 Likes

That looks very good. Thanks.