Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preventing SIGQUIT from terminating interactive python

The keystroke Ctrl + \ causes python and ipython to core dump and quit immediately. How can I prevent this? I don't want to disable the key or remap the keyboard.

I have recently moved to a UK keyboard and the backslash/pipe key, which I'm used to having above the Enter key, is now located in between the left shift and the Z key. I find I'm bumping the keyboard shortcut for SIGQUIT pretty frequently and losing all my variables from the interactive interpreter.

like image 444
wim Avatar asked Nov 20 '25 03:11

wim


1 Answers

It seems that you are on a *nix platform. Ctrl\ generates SIGQUIT, so this isn't really as much about Python.

If you want to disable the key combination you could use stty before starting Python:

stty quit undef

Alternatively, use the following to run Python:

stty quit undef; python; stty quit ^\\

which would disable the key mapping before executing python and set it back later.

like image 61
devnull Avatar answered Nov 22 '25 17:11

devnull



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!