IPython's history-search-backward not working

2019-07-04 08:55发布

IPython's history-search-backward feature is one of my favorite features. history-search-backward allows you to type part of a command and then search backward through your readline history for commands that began with that part of the command. By default (I believe) these are bound to UpArrow or Ctrl+P and DownArrow or Ctrl+N (for backward and forward respectively).

They are not working for me. Instead they just go linearly through my history instead of taking into account the characters I've already typed to (allgedly) filter my history.

I'm running IPython 0.13.2 (with Python 2 and 3) on Arch Linux from within XTerm.

If I hit Escape, Ctrl+P, then UpArrow and DownArrow work exactly as I want them to.

Additionally if I change my ipython_config.py to include

c.TerminalInteractiveShell.readline_parse_and_bind = ['"\\e[B": history-search-forward', '"\\e[A": history-search-backward']

then I can just do Escape UpArrow for the desired behaviour. (Here's the rest of my config file.)

Ctrl+V UpArrow produces ^[[A as I expect. I have the python readline library installed (which seems to fix common problems with macs running IPython).

I have these lines in my .bashrc

bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'

and they work exactly as I want them to within bash.

I have no idea what else to try next, so I've come here. Please help, I hope I've included enough information and done enough research.

1条回答
虎瘦雄心在
2楼-- · 2019-07-04 09:30

The culprit was set keymap vi set in my .inputrc. I removed that and IPython history went back to what I expected. Thanks to @Thomas K!

查看更多
登录 后发表回答