Skip to content

Support for history-beginning-search-{forward,backward} #992

Closed

Description

@tiye

By examining the default binds of Fish, I found Fish doesn't use history-search-backward for up arrow. It's quite a habit in Bash to use up arrow for that.
How can I rewrite up arrow and bind it with history-search-backward?

bind \e\eOA history-token-search-backward
bind \e\eOB history-token-search-forward
bind \e\e\[A history-token-search-backward
bind \e\e\[B history-token-search-forward
bind \eO3A history-token-search-backward
bind \eO3B history-token-search-forward
bind \e\[3A history-token-search-backward
bind \e\[3B history-token-search-forward
bind \e\[1\;3A history-token-search-backward
bind \e\[1\;3B history-token-search-forward
bind \cp history-search-backward
bind \cn history-search-forward

The escaped characters in Fish are so hard to read, let alone figuring out which is the up arrow.

Activity

  1. zanchey commented on Sep 8, 2013

    @zanchey
    Member

    Up arrow (bind -k up) is already bound to up-or-search in the default keybindings. Is that not working for you?

  2. tiye commented on Sep 8, 2013

    @tiye
    Author

    It worked, but not acurate enough. For example I use g X where X is a name of a bookmark of directory.
    I type g script g code g dl g docs to jump to each directory.
    When I tap up arrow with a single g, Fish completes with any commans that has g, even like cd g.
    That's the reason I want to add limit and make it work like history-search-backward like in Bash.

  3. ridiculousfish commented on Sep 8, 2013

    @ridiculousfish
    Member

    It sounds like the desire here is a way to do a prefix search.

  4. tiye commented on Sep 9, 2013

    @tiye
    Author

    I was not sure about its name, and could found a bind with history-prefix-search-forward in it.
    Before using Fish I was using such a piece of code in my ~/.bash:

    bind '"\e[A": history-search-backward'
    bind '"\e[B": history-search-forward'
    set show-all-if-ambiguous on
    set completion-ignore-case on

    didn't understand all meanings though..

  5. added this to the fish-future milestone on Oct 5, 2014
  6. jmerkow commented on Nov 13, 2015

    @jmerkow

    Any update on this?

  7. faho commented on Mar 29, 2016

    @faho
    Member

    This seems to be the same as #1072.

  8. stahara commented on Apr 13, 2016

    @stahara

    Reading the up-or-search function, it seems to me the issue here is that commandline -f incorrectly mimics the history-search-backward readline function. The apparent functionality (matching anywhere in a history line) is actually that of history-substring-search-backward. Here is the relevant documentation from readline(3):

    history-search-backward
    Search backward through the history for the string of characters between the start of the current line and the current cursor position (the point). The search string must match at the beginning of a history line. This is a non-incremental search.

    history-substring-search-backward
    Search backward through the history for the string of characters between the start of the current line and the current cursor position (the point). The search string may match anywhere in a history line. This is a non-incremental search.

  9. stahara commented on Apr 14, 2016

    @stahara

    Hm, I see the source of confusion, I think: the bash(1) manpage contradicts this and describes the behavior as implemented in fish.

  10. changed the title [-]How to bind history-search-forward to up arrow?[/-] [+]Support for history-beginning-search-{forward,backward}[/+] on May 13, 2018
  11. half-potato commented on Jun 7, 2019

    @half-potato

    6 years later is there a solution to this? I tried fish for a while but I switched back to zsh because the substring search is never what I want and frustrates me to no end.

  12. ridiculousfish commented on Jun 14, 2019

    @ridiculousfish
    Member

    There's no binding for a history prefix search yet.

  13. pinpox commented on Sep 19, 2019

    @pinpox

    What steps would be required to implement this? I would like to give it a go, but don't know where to start.

  14. domdom commented on Sep 27, 2019

    @domdom
    Contributor

    I've had a go at implementing this. Would you like a PR?

  15. locked as resolved and limited conversation to collaborators on Apr 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions