Reputation: 5162
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)
Upvotes: 5
Views: 1381
Reputation: 85065
The readline
modules in the Apple-supplied system Pythons in OS X do not link with the GNU readline
library since Apple does not ship GNU readline
with OS X (presumably because of license issues). They do link with the BSD editline
library, libedit
, which reads ~/.editrc
and supports a different set of editing commands. See man 5 editrc
for details. As documented here, you can check for the text libedit
in readline.__doc__
to determine whether GNU readline
or BSD editline
is in use. If you really need GNU readline
, you may be able to install the readline
package from PyPI which has a pre-compiled version of the Python readline
module linked with GNU readline
.
Upvotes: 6