Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readline in OS X does not have correct key bindings #30

Closed
ipython opened this issue May 10, 2010 · 3 comments
Closed

readline in OS X does not have correct key bindings #30

ipython opened this issue May 10, 2010 · 3 comments
Labels
Milestone

Comments

@ipython
Copy link
Collaborator

ipython commented May 10, 2010

Original Launchpad bug 516716: https://bugs.launchpad.net/ipython/+bug/516716
Reported by: ben-j-schiller (thesylex).

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

@takluyver
Copy link
Member

Is this still an issue in trunk?

@minrk
Copy link
Member

minrk commented Apr 12, 2011

Yes, this is still true, but it isn't true that this is an IPython bug, or even an IPython issue at all. Making these changes in IPython would mean that IPython would behave in a different manner to other readline applications on the platform (e.g. bash). A better answer for people who want readline on OSX to behave like readline on Linux is to add the corresponding lines to ~/.inputrc. This would change the behavior for all readline applications, including IPython.

The main remaining point is that history search could be bound to PageUp/Down instead of arrow Up/Down, which would be more standard (though not matching defaults on any system I have used, to my knowledge), and is purely a matter of preference. For me (and especially my PageUp-less laptop keyboard), history search is far too useful to be relegated to the incredibly inconvenient PageUp/Down by default, and if users want it that way, it's easy to change it.

Marking this an an enhancement, since it's a style choice not a bug, but I'd actually recommend just closing this issue, as it really isn't for IPython, but readline on OSX in general.

@minrk
Copy link
Member

minrk commented Apr 19, 2011

Pinging @fperez or @ellisonbg for confirmation, but I vote for closing this Issue as 'not an IPython Issue'. I think the very most we should do is provide links in documentation about readline configuration via inputrc, such as: http://tiswww.case.edu/php/chet/readline/readline.html#SEC9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants