When using the REPL, is there a way to have an ipython-style confirmation when pressing Ctrl-D to exit? Currently Julia does this:
julia> Type ^D again to exit.
julia>
I’m not a fan of this because I think it’ll just train me to double-tap Ctrl-D, which can be destructive if using a Julia shell that’s not using my startup.jl (since it’ll exit the shell).
It’s certainly conceivable — it’s purely a REPL user-interface feature, so it wouldn’t be breaking. You could submit a PR to modify this code to implement it.
I’m not sure whether it would be accepted — I don’t have strong feelings either way myself — but it’s certainly a reasonable proposal.
The issue isn’t that I’d accidentally press ctrl-D — I’d almost certainly ever press it intentionally — but rather that I’d have some old REPL session open in terminal that I hadn’t used in a while, I’d come across it and say “I don’t need this anymore, let me exit out” and then as soon as I did I’d say “oh shoot I did still want something from that REPL”. The confirmation prompt is to give me a chance to think twice.
Coming from Stata, I am so used to CTRL-D for executing lines of code that I have created a shortcut in VScode that does it. I exit Julia by accident every time I update my system and forget to setup my shortcuts. I would love this feature.
I think it’ll just train me to double-tap Ctrl-D, which can be destructive if using a Julia shell that’s not using my startup.jl
That might be an argument in favor of having the confirm_exit option on by default.
Also, you can also press Ctrl-D twice in ipython to exit, so I actually never press Ctrl-D followed by y<Enter>, because it’s less direct than double Ctrl-D. So having the option to type y doesn’t help me in avoiding risking quitting the shell.
I would be fine having the same UI as ipython (where double Crtl-D is a hidden option), but would be reluctant to remove the possibility to type Ctrl-D twice to exit.
Sorry for reviving this old topic, but recently I often incidentally hit Ctrl-D, and I strongly wish to remove the possibility to type Ctrl-D to exit, either once nor twice.
The reason is that Infiltrator.jl uses Ctrl-D to continue. The case I met so often these days is roughly like the following.
I find a bug, and when debugging, I open two terminals, then I run in each terminal a task that different in settings, but with the same breakpoints.
I have some idea, so I use @exit to leave this debugging, and add new breakpoints.
I run the task again in the first terminal, and find that I need to skip 3 or 4 times (because the breakpoint is in a loop) until the bug occurs.
I need to, in the second terminal, hit Ctrl-P to evoke the last command, hit Enter to run it, then hit Ctrl-D 3 or 4 times to get to the same place. However, I forget to hit Ctrl-P and Enter, and with hitting Ctrl-D 3 or 4 times, I leave the REPL. Now I have to open it again and wait for the long long precompilation to continue my debugging.
It is clear that in this case, allowing hitting Ctrl-D alone to leave the REPL will lead to the same problem, whether you need to hit it once or twice. Only forcing hitting another key to leave can save me. A better solution may be that Infiltrator.jl uses another shortcut to continue, but I doubt whether such a change is possible, since it has been widely used, and it is a change that will affect nearly everyone using it.
I have Ctrl-d mapped to select words with multiple cursors (I believe I learned this from SublimeText way back), and use that constantly. If focus is in the REPL instead of the editor, bam.