Skim: A fuzzy finder written in rust


#1

Hi there,

EDIT: just changed the project name to skim as suggested by hoodie.

I’d like to share a project I recently working on: skim.
It is a re-implementation of the famous fzf which is a really handy fuzzy finder. To those who haven’t heard about fzf, it is a general fuzzy finder for command line. That means it is just like an interactive version of grep that enables you to fuzzy find out the target.

A little preview here:

demo

Looking forward for your comments, suggestions, idea, etc.


#2

Simpler install instructions for the lazy:

$ cargo install --git https://github.com/lotabout/fzf-rs.git

#3

Nice! It’s really snappy. Most fuzzy file finders I’ve used tend to be excruciatingly slow on large directories.


#4

I like it.
Would be awesome if I could enter something like $ fzf vim and it would start vim unless I abort.
Because with vim $(fzf) it currently launches vim without a file.


#5

Alternatively, it could just exit with a non-zero status so you would write FILE="$(fzf-rs)" && vim "$FILE"


#6

I’m thinking about the ideal way to integrate fzf with other programs, currently fzf-rs serves as a general purpose text filter.

The possible ways I can think of are (now for this vim case only):

  1. fzf-rs | xargs -o vim to open the file
  2. Write a plugin for vim to invoke fzf-rs inside vim. Note that original fzf provide such plugin which fzf-rs is compatible with.
  3. serve fzf-rs as a general menu for execution, that means we can specify the callback command for selection. Just like fzf-rs --callback execute('vim {}').

#7

Is there any better suggestions on the name? So bad at naming :sweat_smile:.

I think fzf-rs is hard to type and too close to fzf.


#8

I’d be fine with fzf, but I didn’t know about the go version until you mentioned it :smiley:
Something unfancy perhaps? ffind or fzz?


#9

Getting some compilation errors on Windows 10/64 bit.

   Compiling ncurses v5.80.0
H:\devel\MinGW\msys\home\kirillkh\.cargo\registry\src\github.com-1ecc6299db9ec823\ncurses-5.80.0\src\ncurses.rs:78:22: 78:24 error: mismatched types [E0308]
H:\devel\MinGW\msys\home\kirillkh\.cargo\registry\src\github.com-1ecc6299db9ec823\ncurses-5.80.0\src\ncurses.rs:78 { unsafe { ll::addch(ch) } }
H:\devel\MinGW\msys\home\kirillkh\.cargo\registry\src\github.com-1ecc6299db9ec823\ncurses-5.80.0\src\ncurses.rs:78:22: 78:24 help: run `rustc --explain E0308` to see a detailed explanation
H:\devel\MinGW\msys\home\kirillkh\.cargo\registry\src\github.com-1ecc6299db9ec823\ncurses-5.80.0\src\ncurses.rs:78:22: 78:24 note: expected type `u32`
H:\devel\MinGW\msys\home\kirillkh\.cargo\registry\src\github.com-1ecc6299db9ec823\ncurses-5.80.0\src\ncurses.rs:78:22: 78:24 note:    found type `u64`

etc


#10

Obviously, it should be called mold (1, 2).


#11

Windows is not supported for now.

As you know, fzf-rs currently depends on ncurses which did not support windows.


#12

how about skim?

  • short
  • descriptive
  • I could not find tool unix tool by that name in 30secods :smiley:

#13

I see that you used ncurses to implement the UI, does that give you Windows support? I implemented the Heatseeker UI directly in terms of terminal control codes (for POSIX terminals) and the Windows API (for Windows), and as tedious as that was I really like how smoothly it integrates into the command line as a result:


#14

It is ncurese-rs, the library that I use that caused the error on Windows. Plus I uses some *nix-specific stuff(e.g signal handling for terminal resize: SIGWINCH).

BTW, terminal control codes seems really cool! Thank you for the information!


#15

Oh, I see that you already addressed Windows support. SIGWINCH is a tricky one, I wish we had a way to do that (and in particular, to register a signal handler) without going through libc.


#16

A suggestion: in this file - skim/src/event.rs - instead of repeating Event:: you say:

    ...
    use Event::*;
    match action {
        "abort"                =>   Some(EvActAbort),
        "accept"               =>   Some(EvActAccept),
        //rest

#17

This is a pretty amazing contribution to the Rust community, and so I commend you for your efforts. Would you be interested in dumping the dependency on ncurses for a native Rust solution, perhaps with termion? Seems like it would make a good contribution to the RedoxOS project as well, perhaps as a contribution to extrautils.


#18

Thank you! I’d like to contribute to RedoxOS, it looks cool! However I think skim is far from complete, so I’d like to focus on the functionalities for now, and put off the dependency things.