From 37863a8bd6c07cecbcca4b244dd80ff4139169fb 2016-07-28 22:41:06 From: Matthias Bussonnier Date: 2016-07-28 22:41:06 Subject: [PATCH] Quit IPython on Ctrl-\ (SIGQUIT) Closes #9810 --- diff --git a/IPython/terminal/shortcuts.py b/IPython/terminal/shortcuts.py index 5c32b08..456d4e3 100644 --- a/IPython/terminal/shortcuts.py +++ b/IPython/terminal/shortcuts.py @@ -26,6 +26,8 @@ def register_ipython_shortcuts(registry, shell): & insert_mode ))(newline_or_execute_outer(shell)) + registry.add_binding(Keys.ControlBackslash)(force_exit) + registry.add_binding(Keys.ControlP, filter=(ViInsertMode() & HasFocus(DEFAULT_BUFFER) ))(previous_history_or_previous_completion) @@ -145,6 +147,12 @@ def reset_search_buffer(event): def suspend_to_bg(event): event.cli.suspend_to_background() +def force_exit(event): + """ + Force exit (with a non-zero return value) + """ + sys.exit("Quit") + def indent_buffer(event): event.current_buffer.insert_text(' ' * 4)