IPython的历史搜索 - 后退不能按预期工作 [英] IPython's history-search-backward not working as desired

查看:177
本文介绍了IPython的历史搜索 - 后退不能按预期工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IPython的 history-search-backward 功能是我最喜欢的功能之一。 history-search-backward 允许您键入命令的一部分,然后向后搜索readline历史记录,查找以该命令部分开头的命令。默认情况下(我相信)这些绑定到 UpArrow Ctrl + P DownArrow Ctrl + N (分别为向后和向前)。

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.

我正在运行IPython 0.13。在Linux上从XTerm中获得2(使用Python 2和3)。

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

如果我点击 Escape Ctrl + P ,然后 UpArrow DownArrow 完全按照我的要求工作。

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

此外,如果我改变我的 ipython_config.py 包含

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']

那么我可以做 Escape UpArrow 以获得所需的行为。 (这是配置文件的其余部分。)

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

Ctrl + V UpArrow 按照我的预期生成 ^ [[A >。我安装了python readline 库(这似乎解决了运行IPython的mac的常见问题)。

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).

我有这些行在我的 .bashrc

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

它们的工作方式完全符合我的要求 bash

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.

推荐答案

罪魁祸首是 set keymap vi 在我的 .inputrc 中设置。我删除了它,IPython的历史又回到了我的预期。感谢 @Thomas K

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!

这篇关于IPython的历史搜索 - 后退不能按预期工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆