4

Trying to beef up my regular python console, I wanted to add vi-style editing.

1st thing: python is not reading ~/.inputrc if I understand well.

Then, I tried to do (through ~/.pythonrc.py):

import readline
readline.parse_and_bind('set editing-mode vi')

Nothing's happening. Did I miss something? Or is it a problem with my terminal?

I'm on OS X using Terminal.app

(tried rlwrap with no success)

4

1 回答 1

5

Apple 提供的 OS X 系统 Python 中的readline模块不与 GNUreadline库链接,因为 Apple 没有readline随 OS X 一起提供 GNU(可能是因为许可证问题)。它们确实与 BSDeditline库链接,该库libedit读取~/.editrc并支持一组不同的编辑命令。详情请参阅man 5 editrc。如此所述,您可以检查其中的文本libeditreadline.__doc__确定使用的是 GNUreadline还是 BSD editline。如果你真的需要 GNU readline,你可以readline从 PyPI 安装包,readline它有一个与 GNU 链接的 Python 模块的预编译版本readline

于 2013-04-18T22:25:04.740 回答