IPython - Enhanced Interactive Python

readline in OS X does not have correct key bindings

Reported by Ben Schiller on 2010-02-03
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

I'm using OS X 10.5.8, and have installed Python 2.6.4 (not using the built-in version). I have confirmed the same problem with OS X 10.6.2. I compiled iPython 0.10 against Python 2.6.4, and the following keys do not work: home, end, page up page down (for history searching), ctrl/esc + left/right for word navigation.

Here's a fix (for default ipythonrc)

readline_parse_and_bind "\e[1~": beginning-of-line
readline_parse_and_bind "\e[4~": end-of-line
readline_parse_and_bind "\e[5~": history-search-backward
readline_parse_and_bind "\e[6~": history-search-forward
readline_parse_and_bind "\e[5C": forward-word
readline_parse_and_bind "\e[5D": backward-word
readline_parse_and_bind "\e\e[C": forward-word
readline_parse_and_bind "\e\e[D": backward-word

These are the standard key bindings and should be compatible with all *nix systems (someone please test linux). Note that these are not the standard OS X key bindings in Terminal, but should be compatible with them. In particular, Terminal uses shift+page up/down instead of page up/down for the escape codes I used. I gave the forward/backword-word bindings for OS X and linux. Home/end are simply disabled in Terminal by default and people will have to fix that themselves.

Also, the implementation in ipython of up/down for history searching is non-standard. I recommend using page up/down as I have it here, and changing up/down to use all of history. I can see by the comments that people have already complained about this....

Changed in ipython:
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers