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

Add history reverse-isearch #602

Closed
ghost opened this issue Feb 28, 2013 · 106 comments · Fixed by #9089
Closed

Add history reverse-isearch #602

ghost opened this issue Feb 28, 2013 · 106 comments · Fixed by #9089
Assignees
Milestone

Comments

@ghost
Copy link

ghost commented Feb 28, 2013

While I love most things about fish, I had to switch back to zsh because C-r in zsh (or even bash) is more efficient than fish's reverse-search functionality.

In zsh you can type-to-complete substring-matches in history. With fish, you can cycle to see what in your history matches your substring, but you can't easily modify your substring while searching to narrow down the match.

For example if I type "git re" and go up a few times, I may find that I'm only finding a bunch of "git reset"-ish commands, but I know I want a command like "git rebase", so in zsh or bash I would just type a "b" to narrow that down. But in fish I have to restart my search with C-c and try again with "git reb". Otherwise I'm just adding a "b" to the end of whatever the last match was, which isn't what I meant to do.

This may appear trivial, but I rely heavily on C-r for all my commands (which is one reason I like fish, because it predicted that correctly about me), but I rely on it for substring-matches, not just prefix-string matches like fish does with auto-suggestions.

I'm proposing that in addition to the existing reverse-search feature, a zsh-like C-r be implemented as well.

@ridiculousfish
Copy link
Member

I'm interested in suggestions for what the UI ought to be. Currently typing a character during history search just appends it, which seems not very useful, so we have an opportunity to do something better.

@ghost
Copy link
Author

ghost commented Mar 1, 2013

I'm imagining it working exactly like zsh. And since there is no C-r right now in fish, it could even have the same key-binding, and be considered a new feature, instead of a change of existing functionality.

@zanchey
Copy link
Member

zanchey commented Mar 2, 2013

C-r is awfully undiscoverable, though; typing during the history search altering the search term makes more sense to me. You can push the right arrow key if you want to append to something.

@ghost
Copy link
Author

ghost commented Mar 2, 2013

Then how about a mix of fish's C-p/up and zsh's C-r? You could just type something and go up and down in history (with either C-p/C-n or up/down, but the UI would be just like zsh's, where you see the search term on the second line (which is really where your cursor is) but the matches show up on the first line with the matched part underlined (or whatever custom font the user chooses for highlighting matches; currently the default red-background is unreadable). I've attached two screenshots to explain better. But ultimately what I'm suggesting is that the functionality work just like zsh, but it be triggered simply by going up/down through history after/while typing.
Screen Shot 2013-03-02 at 8 22 07 AM
Screen Shot 2013-03-02 at 8 22 36 AM

@ghost
Copy link
Author

ghost commented Mar 4, 2013

As a slight addendum to my UI proposal, instead of being exactly like zsh's UI, the match and the currently-typed-string can be switched, so that what you're typing stays on your current line, but the suggested match appears on the line below.

@Tinche
Copy link
Contributor

Tinche commented Apr 20, 2013

Just wanted to chime in, I recently switched to fish and am really missing this.

@b-rodrigues
Copy link

This feature would be a great addition to fish.

@dag
Copy link
Contributor

dag commented May 17, 2013

How about make it behave mostly like the current behavior rather than like CTRL-R, but don't move the cursor and only "exit" search mode with CTRL-F and friends?

git re CTRL-P git re[s]et b git reb[a]se CTRL-F git rebase

@suvash
Copy link

suvash commented Aug 1, 2013

This would really be a great addition to fish. Recently started using it and only thing I miss at the moment (apart from setting inline environment variables)

@jbergstroem
Copy link

Just wanted to chip in and say that C-r is a pattern I frequently use(d).

@danielb2
Copy link
Contributor

👍

C-r from bash. I looked at fish extensively yesterday. Lack of C-r, something I use not just with the shell, but MANY CLI (mysql, REPL's etc) is problematic. I'm glad I found https://github.com/sjl/z-fish which made things a lot better for me, but I would really like to just see a regular C-r implementation. They work the same across the board.

For bash, I've also remapped C-f to do a forward search by adding "\C-f": forward-search-history to .inputrc. That's also useful for bash.

@ridiculousfish
Copy link
Member

Two problems we should avoid with bash and zsh style reverse history search are the undiscoverable key combination, and the "weird modal state" it puts you in. By that I mean that pressing ctrl-R drops the user into this confusing modal state that changes your prompt, changes what certain keys do, and doesn't provide an obvious way out.

Here's one UI proposal:

  1. Today, when pressing Up, the history match is shown with the cursor positioned at the end of the line. Instead, position it at the end of the search match (the highlighted text). Pressing up again will reposition the cursor to the end of the next match.
  2. If you do text input or deletion anywhere within the highlighted text (including at the end), it will adjust the search to the next match. If there is no next match, it will show you only the text you've inputted.

This might produce a weird "jumping around" effect as you type. I'm not sure how common or bad that would be in practice.

@danielb2
Copy link
Contributor

Even though the interface to i-reverse-search may be confusing it is orthodox and a very standard model. There are two ways you make successful design: by convention or by intuition. I'd say i-reverse-search present in both bash and zsh is convention based on having coming across it on a large number of CLI's.

So if the choice is to go against convention, then it should be intuitive. I'm not sure what was described is intuitive enough to challenge convention.

That's my take on it anyway.

@suvash
Copy link

suvash commented Sep 1, 2013

@ridiculousfish 👍 that sounds quite similar and idiomatic fish as well.

@muescha
Copy link

muescha commented Sep 21, 2013

@ridiculousfish 👍 its great. its similar to up/down without text to search in history.

to avoid weird "jumping around" it can be an option just switch it to similar to i-reverse-serch UI:

$> myS

 now with up/down it goes to and highlight and marked the matches 
 but cursor stays at end of search text and i can edit it
      |             ___
$> myS  --> /myPath/mySoftware 

  when i select it then it becomes
$> /myPath/mySoftware

  great would be if i can see the previous and next matches right around
  and see which i can select with how many up/downs
  while i hit up and down i see the next matching lines from the history

           /mySubproject
           /myPath/mySearch 
$> myS --> /myPath/mySoftware
           /myPath/myStatus
           /myPath/myTestPath/mySecond


  or display the indedx so i see the line counts better

        +2 /mySubproject
        +1 /myPath/mySearch 
$> myS --> /myPath/mySoftware
        -1 /myPath/myStatus
        -2 /myPath/myTestPath/mySecond

there should be a setting for the range how many lines above / below i can see

@gjedeer
Copy link

gjedeer commented Oct 31, 2013

I'm using fish for a few days now and lack of ctrl-r (or equivalent) is the only show stopper for me.

@umbrae
Copy link

umbrae commented Oct 31, 2013

Just to add a "me-too", I stopped using fish because of lack of ctrl-r. Fantastic shell in almost every other respect.

@danielb2
Copy link
Contributor

me too. this is what made me stop using it eventually.

@ridiculousfish
Copy link
Member

@gjedeer @umbrae @danielb2 What is it you like about ctrl-r, that isn't served by the up-arrow history search?

@umbrae
Copy link

umbrae commented Oct 31, 2013

I think there's a number of things, but the sad, true part is probably just habit. :\ It's true that the key combo is not discoverable, but once you've discovered it, it's an awfully hard habit to break. Up arrow history search works fine, but as it is now once you hit the up arrow you can no longer modify your search query. Maybe what you've described above improves on that.

If you'll let me be a dumb user and just say "habit" for now though, I think that's the truest answer.

@gjedeer
Copy link

gjedeer commented Oct 31, 2013

@ridiculousfish Nothing, really. I had no idea it exists. I searched for "history search" and such in the documentation and haven't found it. Maybe you should create a FAQ question - "what about ctrl-r?" :)

@danielb2
Copy link
Contributor

I guess it was ignorance on my part. I think the only thing I don't like about it is that I have to use the arrow keys to page through the results. ctrl-r is more accessible. Can I remap ctrl-r to do that?

@ridiculousfish
Copy link
Member

You could write bind \cr history-search-backward, which will make control-r do the same thing as up-arrow. However the interface is still a little different: in zsh you type ctrl-r and then the search term, while in fish you type the search term and then up-arrow to find it.

@danielb2
Copy link
Contributor

While it's a vast improvement over not having anything at all, I'll maintain my earlier position in that there's value in the convention that reverse-search has since it's uniform over so many programs. It's a common readline deal. Tools such as rlwrap do it this way too.

@Tinche
Copy link
Contributor

Tinche commented Nov 2, 2013

In the meantime, I've gotten quite used to using up-arrow for the history search. Consider my comment from 7 months ago revoked.

If we can get a nice solution that would allow modifying the search term, great, if not, c'est la vie.

@jonhoo
Copy link
Contributor

jonhoo commented Dec 1, 2013

I think the many people saying that this is mostly a matter of habit are right; the fish reverse search is not intrisically less intuitive or less powerful that the bash equivalent. I do think that the choice of the up arrow as the only shortcut for accessing it may make it less accessible though. Not in the sense of discoverability, but with regard to speed of access. As mentioned above, it is a simple matter to bind it to something like ^R as well, but as pointed out by @ridiculousfish, the functionality is not exactly the same, and so this might be confusing. Having another keybinding closer to the home row by default might immediately make this feature more useful.

@brentd
Copy link

brentd commented Dec 2, 2013

Would love to see this in fish. It's the one and only feature I miss from other shells.

I've taken @ridiculousfish's advice and remapped ctrl-r to the up arrow's functionality, but it's definitely not the same. I've gotten very used to seeing history results as I type, and love zsh's implementation which underlines the matched token in the result. Implementing this in fish could also be an opportunity to improve on the canonical implementation with a bit of fuzzy searching as well.

A drawback of remapping ctrl-r to up arrow is that it skips the most recent search result, since the most recent is the one fish autosuggests and expects right arrow (or ctrl-f) to complete – that is, if you're starting your search with the command name as opposed to a substring. Having to keep all this in mind is apparently more mental strain than I can handle on daily basis ;)

So big 👍 to see this in fish. I doubt I would end up being very successful, but @ridiculousfish I wonder if you could mention a starting point for someone like me who wouldn't mind giving the implementation a shot?

@KamilaBorowska
Copy link
Contributor

@brentd: The starting point would be reader.cpp where most of keys are implemented.

@dontdieych
Copy link

I thought fish's autosuggestion as one step further than other shell's interactive search. It was more discoverable and helpful. But we are so missing about C-r's search keyword editing feature.

I'm think about stack like input status history.

  • Up, C-p : push current input status(string) then start backword-search.
  • C-c : forget current input status then pop last input status.
$ open Down<C-p>
$ (look around with couple of C-p then realize there is so many search results)
$ <C-c>
$ open Down (restore last input status before backword-search)
$ open Downloads/pdf<C-p> (type something more, look again)
$ open Downloads/pdf/this-is-not-what-I-want.pdf (oh, stupid, it was .txt file not pdf)
$ <C-c>
$ open Downloads/pdf
$ open Downloads/txt<C-p> (edit, search again)
$ open Downloads/txt/fish-explained.txt(OK, found it)<Enter>

If you need clean prompt, hit C-c twice.

One more thing popped up in my head. If you know g- key in vim, that's it. vim call this 'undo branch' or 'undo tree'. Maybe other editors has this feature too. It is basically branch changing in git like source control tools.

In previous example, we reached 'open Downloads/pdf' at some moment then dropped it. But if we need those previous moments again, we should edit again.

If we saved previous abandoned state history, we can go back through our editing history. And some key could be binded for this history look around feature.

According to previous example, we have three input history.

  • open Down
  • open Downloads/pdf
  • open Downloads/txt
  • (current)

It could be quite helpful if we can 'backword-input-state-search'. You can think this as template for some frequently used command pattern.

@Thovthe
Copy link

Thovthe commented Mar 24, 2020

@krobelus you are making fish 3.2.0 look very tasty, keep up the good work.

krobelus added a commit to krobelus/fish-shell that referenced this issue Mar 25, 2020
When pressing Control-R, fish will start a new incremental search,
(if a search is already active it will be turned into an incremental one).

Incremental search means that whenever you change the search term and it
does not match the current history entry anymore, then fish will
continue the search (in the same direction as the previous search command).

This also adds a system test using tmux' scripting capabilities.
It's not ideal since we have to use sleep all over the place.

Closes fish-shell#602
krobelus added a commit to krobelus/fish-shell that referenced this issue Mar 25, 2020
When pressing Control-R, fish will start a new incremental search,
(if a search is already active it will be turned into an incremental one).

Incremental search means that whenever you change the search term and it
does not match the current history entry anymore, then fish will
continue the search (in the same direction as the previous search command).

This also adds a system test using tmux' scripting capabilities.
It's not ideal since we have to use sleep all over the place.

Closes fish-shell#602
krobelus added a commit to krobelus/fish-shell that referenced this issue Mar 29, 2020
When pressing Control-R, fish will start a new incremental search,
(if a search is already active it will be turned into an incremental one).

Incremental search means that whenever you change the search term and it
does not match the current history entry anymore, then fish will
continue the search (in the same direction as the previous search command).

Closes fish-shell#602
@ahmeed83
Copy link

This one did the job!

https://github.com/jethrokuan/fzf

krobelus added a commit to krobelus/fish-shell that referenced this issue Apr 21, 2020
When pressing Control-R, fish will start a new incremental search,
(if a search is already active it will be turned into an incremental one).

Incremental search means that whenever you change the search term and it
does not match the current history entry anymore, then fish will
continue the search (in the same direction as the previous search command).

Closes fish-shell#602
krobelus added a commit to krobelus/fish-shell that referenced this issue Apr 22, 2020
When pressing Control-R, fish will start a new incremental search,
(if a search is already active it will be turned into an incremental one).

Incremental search means that whenever you change the search term and it
does not match the current history entry anymore, then fish will
continue the search (in the same direction as the previous search command).

Closes fish-shell#602
@jdz
Copy link

jdz commented Apr 24, 2020

Will the "new" incremental search feature also support wildcards, and will it be possible to switch search direction? Like with ZSH's history-incremental-pattern-search-backward and history-incremental-pattern-search-forward functions?

Funny that I started trying Fish yesterday, and this is the feature I need, and it's been controversial since 2013. Also sad.

@fish-shell fish-shell deleted a comment from Nemoden Apr 24, 2020
@psychoslave
Copy link

Interesting to see how the Fish team is staying focus on its philosophy. That's the second topic where I meet it, after the one on bang.

While I understand the point of discoverability, I don't see how using C-p as a alternative of C-r is any better.

On the same level C-f to complete the current line with the suggestion is not more discoverable, you have to read the documentation. I had to check, and it seems that in the defaults, right arrow do the same completion. But it's so less convenient to my habits that I almost forgot it and had to check to see if it works that way. My point is, for many user the right arrow is more discoverable, and that's fine for them. The existence of C-f doesn't hurt this kind of user profile. On the other hand, those who prefer something less distant from base position on the keyboard will be better served with C-f and can forget about the right arrow binding.

Now, sure there are surely way to work around with custom plugins and so on, but given that the C-r is so common in other CLI (not only shells), I don't find especially friendly to have to configure external tools to obtain this basic expectation. Those who don't know C-r wouldn't be hurt by it's existence as a default, and those who are already accustomed with such a feature in CLI would be better served with its default support.

All that said, I must say I appreciate the team philosophy and hope this comment doesn't feel to harsh. Thanks for this wonderful tool.

@fish-shell fish-shell locked and limited conversation to collaborators May 21, 2020
@faho
Copy link
Member

faho commented May 21, 2020

Okay, I've locked this issue as it's going in circles. Please direct your constructive comments regarding the implementation towards #6686 instead

@fish-shell fish-shell deleted a comment from psychoslave May 21, 2020
sekoenig pushed a commit to sekoenig/fish-shell that referenced this issue Jan 17, 2021
When pressing Control-R, fish will start a new incremental search,
(if a search is already active it will be turned into an incremental one).

Incremental search means that whenever you change the search term and it
does not match the current history entry anymore, then fish will
continue the search (in the same direction as the previous search command).

Closes fish-shell#602
krobelus added a commit to krobelus/fish-shell that referenced this issue Jan 22, 2021
When pressing Control-R, fish will start a new incremental search,
(if a search is already active it will be turned into an incremental one).

Incremental search means that whenever you change the search term and it
does not match the current history entry anymore, then fish will
continue the search (in the same direction as the previous search command).

Closes fish-shell#602
d-e-s-o pushed a commit to d-e-s-o/fish-shell that referenced this issue Mar 19, 2021
When pressing Control-R, fish will start a new incremental search,
(if a search is already active it will be turned into an incremental one).

Incremental search means that whenever you change the search term and it
does not match the current history entry anymore, then fish will
continue the search (in the same direction as the previous search command).

Closes fish-shell#602
krobelus added a commit to krobelus/fish-shell that referenced this issue Jul 26, 2022
This reimplements ridiculousfish/control_r which is a more future-proof
approach than fish-shell#6686.

On the surface, this works just like in other shells.

A few differences:

1. Our pager can show multiple results at a time.
2. We use the current token as initial query. This makes it more consistent
   with up-arrow search, though I wonder if this is actually useful?
3. We only replace the current token, not the entire commandline. (Does this
   make sense?)
4. Other shells allow to use up arrow/down arrow to select adjacent entries
   in history. Shouldn't be hard to implement but it might confuse users.
5. In other shells, pressing Return immediately runs the command.
6. We add a space after an accepted completion. This is trivial to change
   but the space is harmless since it's trimmed before adding the command
   to history.

The pager shows at most 10 history items at a time.  This keeps everything
snappy even with huge histories, though I'm sure there are other solutions
for that.

Users might expect the history pager to use subsequence matching (fuzzy
matching) like the completion pager, however for simplicity it uses
substring matching.  We could change this in future, however that means
we would also want to change the ordering from "reverse-chronological" to
"longest common subsequence" (e.g. what fzf does), because otherwise a query
"fis" might give this ordering:

            fsck /dev/disk/by-partlabel/Linux\x20filesystem
            fish

which is probably not what the user wants.

Closes fish-shell#602
krobelus added a commit to krobelus/fish-shell that referenced this issue Jul 27, 2022
This reimplements ridiculousfish/control_r which is a more future-proof
approach than fish-shell#6686.

On the surface, this works just like in other shells.

A few differences:

1. Our pager can show multiple results at a time.
2. We use the current token as initial query. This makes it more consistent
   with up-arrow search, though I wonder if this is actually useful?
3. We only replace the current token, not the entire commandline. (Does this
   make sense?)
4. Other shells allow to use up arrow/down arrow to select adjacent entries
   in history. Shouldn't be hard to implement but it might confuse users.
5. In other shells, pressing Return immediately runs the command.
6. We add a space after an accepted completion. This is trivial to change
   but the space is harmless since it's trimmed before adding the command
   to history.

The pager shows at most 10 history items at a time.  This keeps everything
snappy even with huge histories, though I'm sure there are other solutions
for that.

Users might expect the history pager to use subsequence matching (fuzzy
matching) like the completion pager, however for simplicity it uses
substring matching.  We could change this in future, however that means
we would also want to change the ordering from "reverse-chronological" to
"longest common subsequence" (e.g. what fzf does), because otherwise a query
"fis" might give this ordering:

            fsck /dev/disk/by-partlabel/Linux\x20filesystem
            fish

which is probably not what the user wants.

Closes fish-shell#602
krobelus added a commit to krobelus/fish-shell that referenced this issue Jul 27, 2022
This reimplements ridiculousfish/control_r which is a more future-proof
approach than fish-shell#6686.

On the surface, this works just like in other shells.

A few differences:

1. Our pager can show multiple results at a time.
2. We use the current token as initial query. This makes it more consistent
   with up-arrow search, though I wonder if this is actually useful?
3. We only replace the current token, not the entire commandline. (Does this
   make sense?)
4. Other shells allow to use up arrow/down arrow to select adjacent entries
   in history. Shouldn't be hard to implement but it might confuse users.
5. In other shells, pressing Return immediately runs the command.
6. We add a space after an accepted completion. This is trivial to change
   but the space is harmless since it's trimmed before adding the command
   to history.

The pager shows at most 10 history items at a time.  This keeps everything
snappy even with huge histories, though I'm sure there are other solutions
for that.

Users might expect the history pager to use subsequence matching (fuzzy
matching) like the completion pager, however for simplicity it uses
substring matching.  We could change this in future, however that means
we would also want to change the ordering from "reverse-chronological" to
"longest common subsequence" (e.g. what fzf does), because otherwise a query
"fis" might give this ordering:

            fsck /dev/disk/by-partlabel/Linux\x20filesystem
            fish

which is probably not what the user wants.

Closes fish-shell#602
krobelus added a commit to krobelus/fish-shell that referenced this issue Jul 27, 2022
This reimplements ridiculousfish/control_r which is a more future-proof
approach than fish-shell#6686.

On the surface, this works just like in other shells.

A few differences:

1. Our pager can show multiple results at a time.
2. We use the current token as initial query. This makes it more consistent
   with up-arrow search, though I wonder if this is actually useful?
3. We only replace the current token, not the entire commandline. (Does this
   make sense?)
4. Other shells allow to use up arrow/down arrow to select adjacent entries
   in history. Shouldn't be hard to implement but it might confuse users.
5. In other shells, pressing Return immediately runs the command.
6. We add a space after an accepted completion. This is trivial to change
   but the space is harmless since it's trimmed before adding the command
   to history.

The pager shows at most 10 history items at a time.  This keeps everything
snappy even with huge histories, though I'm sure there are other solutions
for that.

Users might expect the history pager to use subsequence matching (fuzzy
matching) like the completion pager, however for simplicity it uses
substring matching.  We could change this in future, however that means
we would also want to change the ordering from "reverse-chronological" to
"longest common subsequence" (e.g. what fzf does), because otherwise a query
"fis" might give this ordering:

            fsck /dev/disk/by-partlabel/Linux\x20filesystem
            fish

which is probably not what the user wants.

Closes fish-shell#602
krobelus added a commit to krobelus/fish-shell that referenced this issue Jul 27, 2022
This reimplements ridiculousfish/control_r which is a more future-proof
approach than fish-shell#6686.

On the surface, this works just like in other shells.

A few differences:

1. Our pager can show multiple results at a time.
2. Other shells allow to use up arrow/down arrow to select adjacent entries
   in history. Shouldn't be hard to implement but it might confuse users.

The pager shows at most 10 history items at a time.  This keeps everything
snappy even with huge histories, though I'm sure there are other solutions
for that.

Users might expect the history pager to use subsequence matching (fuzzy
matching) like the completion pager, however for simplicity it uses
substring matching.  We could change this in future, however that means
we would also want to change the ordering from "reverse-chronological" to
"longest common subsequence" (e.g. what fzf does), because otherwise a query
"fis" might give this ordering:

            fsck /dev/disk/by-partlabel/Linux\x20filesystem
            fish

which is probably not what the user wants.

Closes fish-shell#602
krobelus added a commit to krobelus/fish-shell that referenced this issue Jul 27, 2022
This reimplements ridiculousfish/control_r which is a more future-proof
approach than fish-shell#6686.

On the surface, this works just like in other shells.

A few differences:

1. Our pager can show multiple results at a time.
2. Other shells allow to use up arrow/down arrow to select adjacent entries
   in history. Shouldn't be hard to implement but it might confuse users.

The pager shows at most 10 history items at a time.  This keeps everything
snappy even with huge histories, though I'm sure there are other solutions
for that.

Users might expect the history pager to use subsequence matching (fuzzy
matching) like the completion pager, however for simplicity it uses
substring matching.  We could change this in future, however that means
we would also want to change the ordering from "reverse-chronological" to
"longest common subsequence" (e.g. what fzf does), because otherwise a query
"fis" might give this ordering:

            fsck /dev/disk/by-partlabel/Linux\x20filesystem
            fish

which is probably not what the user wants.

Closes fish-shell#602
krobelus added a commit to krobelus/fish-shell that referenced this issue Jul 28, 2022
This reimplements ridiculousfish/control_r which is a more future-proof
approach than fish-shell#6686.

On the surface, this works just like in other shells.

A few differences:

1. Our pager can show multiple results at a time.
2. Other shells allow to use up arrow/down arrow to select adjacent entries
   in history. Shouldn't be hard to implement but it might confuse users.

Users might expect the history pager to use subsequence matching (fuzzy
matching) like the completion pager, however for simplicity it uses
substring matching.  We could change this in future, however that means
we would also want to change the ordering from "reverse-chronological" to
"longest common subsequence" (e.g. what fzf does), because otherwise a query
"fis" might give this ordering:

            fsck /dev/disk/by-partlabel/Linux\x20filesystem
            fish

which is probably not what the user wants.

The pager shows only a small number of history items at a time.  This is
because the history pager does not support subsequence matching, so navigating
it does not scale well.

Closes fish-shell#602
krobelus added a commit to krobelus/fish-shell that referenced this issue Jul 28, 2022
This reimplements ridiculousfish/control_r which is a more future-proof
approach than fish-shell#6686.

On the surface, this works just like in other shells.

A few differences:

1. Our pager can show multiple results at a time.
2. Other shells allow to use up arrow/down arrow to select adjacent entries
   in history. Shouldn't be hard to implement but it might confuse users.

Users might expect the history pager to use subsequence matching (fuzzy
matching) like the completion pager, however for simplicity it uses
substring matching.  We could change this in future, however that means
we would also want to change the ordering from "reverse-chronological" to
"longest common subsequence" (e.g. what fzf does), because otherwise a query
"fis" might give this ordering:

            fsck /dev/disk/by-partlabel/Linux\x20filesystem
            fish

which is probably not what the user wants.

The pager shows only a small number of history items at a time.  This is
because the history pager does not support subsequence matching, so navigating
it does not scale well.

Closes fish-shell#602
krobelus added a commit to krobelus/fish-shell that referenced this issue Jul 30, 2022
This reimplements ridiculousfish/control_r which is a more future-proof
approach than fish-shell#6686.
Pressing Control+R shows history in our pager and allows to search filter
commands with the pager search field.

On the surface, this works just like in other shells; though there are
some differences.

- Our pager shows multiple results at a time.
- Other shells allow to use up arrow/down arrow to select adjacent entries
  in history. Shouldn't be hard to implement but the hidden state might
  confuse users and it doesn't play well with up-or-search, so this is
  left out.

Users might expect the history pager to use subsequence matching (fuzzy
matching) like the completion pager, however due to the history pager design it
uses substring matching.  We could change this in future, however that means
we would also want to change the ordering from "reverse-chronological" to
"longest common subsequence" (e.g. what fuzzy finders do), because otherwise
a query "fis" might give this ordering:

            fsck /dev/disk/by-partlabel/Linux\x20filesystem
            fish

which is probably not what the user wants.

The pager shows only a small number of history items at a time.  This is
because, as explained above, the history pager does not support subsequence
matching, so navigating it does not scale well.

Closes fish-shell#602
krobelus added a commit that referenced this issue Jul 30, 2022
This reimplements ridiculousfish/control_r which is a more future-proof
approach than #6686.
Pressing Control+R shows history in our pager and allows to search filter
commands with the pager search field.

On the surface, this works just like in other shells; though there are
some differences.

- Our pager shows multiple results at a time.
- Other shells allow to use up arrow/down arrow to select adjacent entries
  in history. Shouldn't be hard to implement but the hidden state might
  confuse users and it doesn't play well with up-or-search, so this is
  left out.

Users might expect the history pager to use subsequence matching (fuzzy
matching) like the completion pager, however due to the history pager design it
uses substring matching.  We could change this in future, however that means
we would also want to change the ordering from "reverse-chronological" to
"longest common subsequence" (e.g. what fuzzy finders do), because otherwise
a query "fis" might give this ordering:

            fsck /dev/disk/by-partlabel/Linux\x20filesystem
            fish

which is probably not what the user wants.

The pager shows only a small number of history items at a time.  This is
because, as explained above, the history pager does not support subsequence
matching, so navigating it does not scale well.

Closes #602
@faho faho modified the milestones: fish-future, fish 3.6.0 Aug 13, 2022
@faho faho changed the title Add zsh-like reverse-isearch Add history reverse-isearch Aug 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.