In ipython, if I press 'esc' followed by 'enter' (and possibly other characters?), readline breaks. I can no longer search through command history using the 'up' key, and some commands (e.g., control-K) fail.
Is there a way to reset readline within an ipython session? What is going on when I press these keys?
The poster's suggested answer doesn't seem to work for me in iPython 0.12+. I can run:
get_ipython().init_readline()
but that doesn't seem to help.
However I noticed that I sometimes see similar problems in my iPython sessions. It appears that I had inadvertently switched from the default Emacs readline editing mode to vi-mode(vim-mode). According to the the readline docs to switch between them you are supposed to be able to use the M-C-j key combination but that only seems to allow me to switch to vi-mode. To switch back to Emacs mode one can use C-e but that didn't appear to work for me - I had to instead do M-C-e - on my Mac (where ESC is used as the 'Meta' key) it is: ESC+CTRL+e
The contents of my ~/.inputrc is as follows:
set meta-flag on
set input-meta on
set convert-meta off
set output-meta on
Got impatient. Solution is:
IPython.InteractiveShell.init_readline(get_ipython())
Looks like this might be a known bug too: http://www.catonmat.net/blog/bash-vi-editing-mode-cheat-sheet/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With