##// END OF EJS Templates
Add and use confirm_exit flag in prompt_toolkit shell...
Thomas Kluyver -
Show More
@@ -8,7 +8,7 b' from IPython.core.interactiveshell import InteractiveShell'
8 from IPython.utils.py3compat import PY3, cast_unicode_py2, input
8 from IPython.utils.py3compat import PY3, cast_unicode_py2, input
9 from IPython.utils.terminal import toggle_set_term_title, set_term_title
9 from IPython.utils.terminal import toggle_set_term_title, set_term_title
10 from IPython.utils.process import abbrev_cwd
10 from IPython.utils.process import abbrev_cwd
11 from traitlets import Bool, Unicode, Dict
11 from traitlets import Bool, CBool, Unicode, Dict
12
12
13 from prompt_toolkit.completion import Completer, Completion
13 from prompt_toolkit.completion import Completer, Completion
14 from prompt_toolkit.enums import DEFAULT_BUFFER
14 from prompt_toolkit.enums import DEFAULT_BUFFER
@@ -54,6 +54,12 b' class TerminalInteractiveShell(InteractiveShell):'
54
54
55 pt_cli = None
55 pt_cli = None
56
56
57 confirm_exit = CBool(True, config=True,
58 help="""
59 Set to confirm when you try to exit IPython with an EOF (Control-D
60 in Unix, Control-Z/Enter in Windows). By typing 'exit' or 'quit',
61 you can force a direct exit without any confirmation.""",
62 )
57 vi_mode = Bool(False, config=True,
63 vi_mode = Bool(False, config=True,
58 help="Use vi style keybindings at the prompt",
64 help="Use vi style keybindings at the prompt",
59 )
65 )
@@ -257,7 +263,8 b' class TerminalInteractiveShell(InteractiveShell):'
257 try:
263 try:
258 code = self.prompt_for_code()
264 code = self.prompt_for_code()
259 except EOFError:
265 except EOFError:
260 if self.ask_yes_no('Do you really want to exit ([y]/n)?','y','n'):
266 if (not self.confirm_exit) \
267 or self.ask_yes_no('Do you really want to exit ([y]/n)?','y','n'):
261 self.ask_exit()
268 self.ask_exit()
262
269
263 else:
270 else:
General Comments 0
You need to be logged in to leave comments. Login now