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

[Idea] replace fzf support with skim library #3

Closed
Th3Whit3Wolf opened this issue Mar 8, 2020 · 5 comments
Closed

[Idea] replace fzf support with skim library #3

Th3Whit3Wolf opened this issue Mar 8, 2020 · 5 comments

Comments

@Th3Whit3Wolf
Copy link

The skim binary is as far as I could tell a direct drop-in replacement for fzf built with rust. I have never used their library but their example on their README

# Cargo.toml
[dependencies]
skim = "0.7.0"
extern crate skim;
use skim::prelude::*;
use std::io::Cursor;

pub fn main() {
    let options = SkimOptionsBuilder::default()
        .height(Some("50%"))
        .multi(true)
        .build()
        .unwrap();

    let input = "aaaaa\nbbbb\nccc".to_string();

    // `SkimItemReader` is a helper to turn any `BufRead` into a stream of `SkimItem`
    // `SkimItem` was implemented for `AsRef<str>` by default
    let item_reader = SkimItemReader::default();
    let items = item_reader.of_bufread(Cursor::new(input));

    // `run_with` would read and show items from the stream
    let selected_items = Skim::run_with(&options, Some(items))
        .map(|out| out.selected_items)
        .unwrap_or_else(|| Vec::new());

    for item in selected_items.iter() {
        print!("{}: {}{}", item.get_index(), item.get_output_text(), "\n");
    }
}

seems simple enough.

@ajeetdsouza
Copy link
Owner

This definitely looks interesting, I will give this a try!

@ErichDonGubler
Copy link
Contributor

The only issue with this is that currently, zoxide is cross-platform. However, tui-rs (made by the @lotabout, the creator of skim to dogfood FOR skim) is *nix-only, and the author has preferred not to take the time to make sure it works with Windows.

@ajeetdsouza
Copy link
Owner

While zoxide currently only supports *nix, I do intend to eventually add Windows support. If skim worsens the gap, it must be counted out.

Thanks!

@NightMachinery
Copy link

skim is also much slower than fzf.

@pickfire
Copy link

pickfire commented Jun 25, 2021

Yes, but it's not noticible unless you have lots and lots of files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants