3 releases

0.1.2 Sep 7, 2018
0.1.1 Aug 27, 2018
0.1.0 Aug 27, 2018

#12 in #find

Download history 24/week @ 2018-08-31 16/week @ 2018-09-07

13 downloads per month

Custom license

41KB
1K SLoC

fzyr

fzyr is a simple and fast fuzzy text search. It exists as both a Rust library and a standalone executable.

Basically fzy re-written in Rust.

Why?

fzyr exists because I wanted a fuzzy finder library while learning Rust. However, you may find that it useful for your purposes

fzyr is very similar to fzy, so inherits its advantages (at least as of Aug 2018). For most purposes it should be usable as a drop-in replacement.

Advantages over fzy:

  • It's works on Windows! Or at least it should, that's not actually been tested yet, let me know if it doesn't πŸ–₯
  • It works with all unicode strings! Hello, rest of the world πŸ—ΊοΈ
  • You can easily install with Cargo! Cross-platform package management πŸ“¦
  • It's a Rust library! Use the algorithm in your own projects πŸ˜€

Disadvantages over fzy:

  • It's less-well tested
  • It doesn't support arbitrary tty i/o (only stdin/stdout)
  • Interactive mode needs more work

Installation

Cargo

You can install on any supported platform using Cargo, Rust's excellent pacakge manager.

$ cargo install fzyr

Linux

You can use Cargo, or if you'd prefer install as a snap

$ snap install fzyr

Homebrew

Might arrive at some point...

Windows

Use Cargo

Usage

Check out fzy for some usage examples.

To search for lines containing "something" in a file:

$ cat very-long-file | fzyr -q something

To search interactively for a file:

$ find . -type f | fzyr

Explore the options with:

$ fzyr -h

Library documentation

Coming soon...

Algorithm

The alorithm is near-identical to that of fzy. That means:

  • Search is case-insensitive (all characters are converted to their unicode-defined lowercase version, if one exists)
  • Results must contain the entire query string, in the right order, but without the letters necessarily being consecutive
  • Results are all given a numerical score, and returned in best-score-first order
  • Prefers consecutive characters and characters that start words/filenames
  • Prefers shorter results

To-do list

Feel free to make a PR if you're so moved

  • Improve interactive mode
  • Library documentation
  • Tests for search_locate()
  • Integration tests
  • Benchmarks
  • Package for various OSs
  • Zero-allocation search
  • Arbitrary tty i/o

Dependencies

~5.5MB
~93K SLoC