# Deactivate Shortcut Control D

**URL:** <https://discourse.julialang.org/t/deactivate-shortcut-control-d/31511>\
**Category:** General Usage\
**Created:** [November 25, 2019, 10:59pm UTC](https://discourse.julialang.org/t/deactivate-shortcut-control-d/31511 "2019-11-25T22:59:11Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Usor](https://avatars.discourse-cdn.com/v4/letter/u/8dc957/32.png) [@Usor](https://discourse.julialang.org/u/Usor)\
**Post date:** [November 25, 2019, 10:59pm UTC](https://discourse.julialang.org/t/deactivate-shortcut-control-d/31511/1 "2019-11-25T22:59:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zgornel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zgornel/32/217487_2.png) [@zgornel](https://discourse.julialang.org/u/zgornel)\
**Post date:** [November 26, 2019, 4:17pm UTC](https://discourse.julialang.org/t/deactivate-shortcut-control-d/31511/2 "2019-11-26T16:17:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Usor](https://avatars.discourse-cdn.com/v4/letter/u/8dc957/32.png) [@Usor](https://discourse.julialang.org/u/Usor)\
**Post date:** [November 26, 2019, 5:15pm UTC](https://discourse.julialang.org/t/deactivate-shortcut-control-d/31511/3 "2019-11-26T17:15:05Z")

</div>

Okay. Thanks.

Would be nice to have it.

---

<div class="post-metadata">

**Author:** ![jpsamaroo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jpsamaroo/32/46804_2.png) [@jpsamaroo](https://discourse.julialang.org/u/jpsamaroo)\
**Post date:** [November 26, 2019, 5:28pm UTC](https://discourse.julialang.org/t/deactivate-shortcut-control-d/31511/4 "2019-11-26T17:28:40Z")

</div>

`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.

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [November 26, 2019, 5:38pm UTC](https://discourse.julialang.org/t/deactivate-shortcut-control-d/31511/5 "2019-11-26T17:38:19Z")

</div>

You can customize the keybindings, see [this manual section](https://docs.julialang.org/en/v1/stdlib/REPL/#Customizing-keybindings-1).

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

```julia
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)

```

---

<div class="post-metadata">

**Author:** ![Usor](https://avatars.discourse-cdn.com/v4/letter/u/8dc957/32.png) [@Usor](https://discourse.julialang.org/u/Usor)\
**Post date:** [November 26, 2019, 7:01pm UTC](https://discourse.julialang.org/t/deactivate-shortcut-control-d/31511/6 "2019-11-26T19:01:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rfourquet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rfourquet/32/3610_2.png) [@rfourquet](https://discourse.julialang.org/u/rfourquet)\
**Post date:** [November 27, 2019, 8:25am UTC](https://discourse.julialang.org/t/deactivate-shortcut-control-d/31511/7 "2019-11-27T08:25:20Z")

</div>

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
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`.

---

<div class="post-metadata">

**Author:** ![Usor](https://avatars.discourse-cdn.com/v4/letter/u/8dc957/32.png) [@Usor](https://discourse.julialang.org/u/Usor)\
**Post date:** [November 27, 2019, 6:18pm UTC](https://discourse.julialang.org/t/deactivate-shortcut-control-d/31511/8 "2019-11-27T18:18:48Z")

</div>

That looks very good. Thanks.
