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

History search bindings in bash break up/down arrow completely #51

Closed
headius opened this Issue Jul 25, 2012 · 9 comments

Comments

Projects
None yet
3 participants
@headius
Copy link
Contributor

headius commented Jul 25, 2012

From JRUBY-6787: http://jira.codehaus.org/browse/JRUBY-6787

When a bash .inputrc contains the following lines, it appears to break up/down arrow behavior in a console using jline:

{noformat}
"\e[A": history-search-backward
"\e[B": history-search-forward
{noformat}

I'm not really familiar with bash, but the readline equivalent to history-search-backward is Ctrl-r, which does work properly in jline.

Expected behavior would be that up and down get bound to (and cause to happen) the appropriate readline equivalents of forward and backward history searching.

@trptcolin

This comment has been minimized.

Copy link
Member

trptcolin commented Jul 25, 2012

OK, this gets history-search-backward handled for inputrc bindings (it was already partially implemented).

Forward history searching is currently not implemented (via Ctrl-s or by any other means). I'd love to have it too, so I'll leave this issue open for that to get in place.

@headius

This comment has been minimized.

Copy link
Contributor Author

headius commented Jul 26, 2012

Cool, that's progress :)

@trptcolin

This comment has been minimized.

Copy link
Member

trptcolin commented May 17, 2013

Forward search is implemented on master as of c985440

Thanks for the report!

@trptcolin trptcolin closed this May 17, 2013

@jszakmeister

This comment has been minimized.

Copy link
Contributor

jszakmeister commented Dec 24, 2013

@trptcolin history-search-backward is not the same thing as Ctrl-r. The latter prompts you do a backwards incremental search. history-search-backward uses what you've typed currently to search backwards in history for a previous line that matches:

Search forward through the history for the string of characters between the start of the current line and the point. This is a non-incremental search.

So you can type something like (println, and hit up and see the most recent line that you typed that begins with (println. Pressing up again will give you the second most recent, etc. It's similar to using Ctrl-r except there is no prompting and it bases the selection on what you've typed so far.

If it's possible, it'd be really nice to have this feature. Ctrl-r is more cumbersome to use, especially when you've got muscle memory built for history-search-backward.

Thanks!

@jszakmeister

This comment has been minimized.

Copy link
Contributor

jszakmeister commented Dec 24, 2013

One more comment. history-search-backward is probably closer to non-incremental-reverse-search-history except the list is filtered by what's from the beginning of the line to the cursor.

@trptcolin

This comment has been minimized.

Copy link
Member

trptcolin commented Dec 24, 2013

@jszakmeister Are you on jline 2.11? I think the behavior you're describing that you want is the same as what I'm seeing on 2.11, via ctrl-r by default, and via my up arrow key if I map it. I type (println, hit whatever shortcut key I set up, and I see the most recent line matching that text.

Have you mapped your arrow keys to the command you want, history-search-backward)? If applicable, keep in mind that arrow key codes can vary widely depending on your OS/locale/terminal combination.

Currently history-search-backward and reverse-search-history are implemented in jline as though they're synonyms, and non-incremental-reverse-search-history is unimplemented (perhaps it should be aliased as well? haven't seen any reports of anyone wanting it, though). I gather that history-search-backward, reverse-search-history, and non-incremental-reverse-search-history are all slightly different things in readline, but I'm not personally inclined to do the research & work to implement them all differently right now. This is because I just want, and have, the ability to hit my shortcut key either before or after typing the stuff I want to search on, and have it search on the current line contents. Happy to help review a patch though.

@jszakmeister

This comment has been minimized.

Copy link
Contributor

jszakmeister commented Dec 24, 2013

@trptcolin How can I tell from reply? Leiningen is saying that reply 0.1.10 is in use. But I did take a look at the source code before actually writing the comment.

I don't want the same behavior as Ctrl-r. Ctrl-r prompts while history-search-backward doesn't. history-search-backward should search based on what I've typed so far without prompting.

Yes, I've mapped the keys and they are working correctly (I mapped them to other things just to check).

Correct, the 3 options do slightly different things. I'll see if I can put something together that does the right thing--for at least history-search-backward.

Thanks!

@trptcolin

This comment has been minimized.

Copy link
Member

trptcolin commented Dec 24, 2013

The current version of REPLy is 0.3.0. I suggest trying that before working on a patch (it's in lein 2.3.4).

@jszakmeister

This comment has been minimized.

Copy link
Contributor

jszakmeister commented Dec 24, 2013

Thanks @trptcolin. I just tried the newest lein and it still behaves the same way (which was expected, since they follow the same paths in jline). I'll see what I can put together over the next week or so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment