fzf preferring lines with exact (single) word match

Created on 26 Aug 2017  Â·  3Comments  Â·  Source: junegunn/fzf

  • Category

    • [x] fzf binary

    • [x] Key bindings

  • OS

    • [x] Mac OS X

  • Shell

    • [x] bash

__fzf_history__ is not working for me as expected. This probably applies to all other fzf commands as well, but it is especially annoying for the reverse-i-search feature.

Correct order (expected order)

  • Notice the consecutive numbers, line starting with 45432 comes before 152202
$ HISTTIMEFORMAT= history | grep shadow
45432  ssh [email protected]
152176  gcob fix-var-shadowing develop
152202  gometalinter --vendor --disable-all --enable vetshadow ./...
152220  gometalinter --vendor --disable-all --enable testshadow ./...
152221  HISTTIMEFORMAT= history | tac | nauniq --ignore-pattern="^\s*\d+\s{0,2}" | tac | grep shadow

Incorrect order (produced by fzf)

  • No consecutive numbers, line starting with 45432 comes __after__ 152202 (this is what I expect --tiebreak=index to solve)
$ __fzf_history__ # Type in 'shadow (with leading single quote to search for an exact match of "shadow" – without quotes)
152202  gometalinter --vendor --disable-all --enable vetshadow ./...
152220  gometalinter --vendor --disable-all --enable testshadow ./...
45432  ssh [email protected]
152176  gcob fix-var-shadowing develop
152221  HISTTIMEFORMAT= history | tac | nauniq --ignore-pattern="^\s*\d+\s{0,2}" | tac | grep shadow

To me it seems that the lines including vetshadow and testshadow are deferred because they don't include shadow as an exact, single word. I suspect this to be a fuzzy-matching feature of fzf, but how to turn it off in this particular case?

question

Most helpful comment

It's enabled by default. See https://github.com/junegunn/fzf#key-bindings-for-command-line

Something you want to see the commands in chronological order, sometimes you want fzf to sort the list by relevance.

All 3 comments

You can turn off sorting by pressing CTRL-R again, or make it default by adding --no-sort to $FZF_CTRL_R_OPTS

Thanks for your quick help @junegunn, works fine now.
What's the use case for the sorting? Any reason this is not enabled by default for Ctrl-R?

It's enabled by default. See https://github.com/junegunn/fzf#key-bindings-for-command-line

Something you want to see the commands in chronological order, sometimes you want fzf to sort the list by relevance.

Was this page helpful?
0 / 5 - 0 ratings