IPython's history-search-backward not working as desired

寵の児 提交于 2019-12-10 20:35:59

问题


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:


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!



来源:https://stackoverflow.com/questions/16350245/ipythons-history-search-backward-not-working-as-desired

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!