Top Related Projects
:cherry_blossom: A command-line fuzzy finder
Fuzzy Finder in rust!
An interactive cheatsheet tool for the command-line
Simplistic interactive filtering tool
A simple, fast and user-friendly alternative to 'find'
ripgrep recursively searches directories for a regex pattern while respecting your gitignore
Quick Overview
fzy is a fast, simple fuzzy text selector for the terminal. It's designed to be a more efficient alternative to other fuzzy finders like fzf, with a focus on speed and simplicity. fzy uses a scoring algorithm that aims to provide more intuitive results for user queries.
Pros
- Extremely fast performance, especially for large datasets
- Simple and intuitive scoring algorithm
- Lightweight with minimal dependencies
- Easy integration with shell scripts and other tools
Cons
- Fewer features compared to more comprehensive tools like fzf
- Limited customization options
- Not as widely adopted as some alternatives
- Lacks some advanced filtering capabilities
Code Examples
# Basic usage: Select a file from the current directory
fzy < <(find . -type f)
# Use with grep to filter and select from command output
history | grep git | fzy
# Integration with vim to open selected file
vim $(find . -type f | fzy)
Getting Started
-
Install fzy:
- On macOS:
brew install fzy
- On Ubuntu/Debian:
sudo apt-get install fzy
- On other systems, compile from source:
git clone https://github.com/jhawthorn/fzy cd fzy make sudo make install
- On macOS:
-
Basic usage:
# Select from a list of items echo -e "apple\nbanana\ncherry" | fzy # Select a file from the current directory find . -type f | fzy # Use selected item in a command vim $(find . -type f | fzy)
-
Add to your shell configuration (e.g.,
.bashrc
or.zshrc
):# Ctrl+F to select a file and open in vim bind '"\C-f": " \C-e\C-u`find . -type f | fzy`\e\C-e\er\C-m"'
Competitor Comparisons
:cherry_blossom: A command-line fuzzy finder
Pros of fzf
- More feature-rich with extensive customization options
- Supports multi-select and preview functionality
- Wider ecosystem with plugins and integrations for various tools
Cons of fzf
- Larger codebase and potentially higher resource usage
- Steeper learning curve due to more complex configuration options
Code Comparison
fzy:
static double calculate_score(const char *needle, const char *haystack) {
double score = 0;
int n_match = 0;
// ... (scoring algorithm implementation)
}
fzf:
func calculateScore(needle, haystack string) int {
// ... (more complex scoring algorithm)
bonus := 0
for _, chunk := range chunks {
bonus += calculateChunkBonus(chunk, prevPos)
}
return score + bonus
}
Summary
fzf offers more features and customization options, making it suitable for power users and complex workflows. It has a larger ecosystem with various integrations. However, this comes at the cost of a larger codebase and potentially higher resource usage.
fzy, on the other hand, is simpler and more lightweight, focusing on speed and a straightforward matching algorithm. It may be preferable for users who need a fast, no-frills fuzzy finder with minimal setup.
The code comparison shows that fzf's scoring algorithm is more complex, potentially offering more accurate matches at the expense of simplicity.
Fuzzy Finder in rust!
Pros of skim
- Written in Rust, potentially offering better performance and memory safety
- More feature-rich, including multi-selection and preview functionality
- Actively maintained with frequent updates and improvements
Cons of skim
- Larger codebase and more complex to contribute to or modify
- May have a steeper learning curve due to additional features
- Slightly higher resource usage compared to fzy's minimal approach
Code comparison
skim (Rust):
pub fn fuzzy_match(choice: &str, pattern: &str) -> Option<(i64, Vec<usize>)> {
if pattern.is_empty() {
return Some((0, vec![]));
}
let choice = choice.to_lowercase();
let pattern = pattern.to_lowercase();
// ... (additional implementation)
}
fzy (C):
int fuzzy_match_recursive(const char *haystack, const char *needle, int k, int *match_positions) {
if (!*needle) {
return k;
} else if (!*haystack) {
return SCORE_MIN;
} else {
// ... (additional implementation)
}
}
Both projects implement fuzzy matching algorithms, but skim uses Rust's type system and ownership model, while fzy opts for a more traditional C implementation. skim's approach may offer better safety guarantees, while fzy's C code could potentially be more performant in certain scenarios.
An interactive cheatsheet tool for the command-line
Pros of navi
- More comprehensive command-line tool, offering interactive cheatsheets and command suggestions
- Supports multiple programming languages and shell environments
- Allows for custom cheatsheet creation and sharing within teams
Cons of navi
- Steeper learning curve due to more complex functionality
- Requires more setup and configuration compared to fzy's simplicity
- Larger codebase and potentially higher resource usage
Code comparison
navi (Rust):
fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = Config::new()?;
let finder = get_finder(&config)?;
let selection = finder.find()?;
println!("{}", selection);
Ok(())
}
fzy (C):
int main(int argc, char *argv[]) {
options_t options;
options_parse(&options, argc, argv);
run(&options);
return 0;
}
Key differences
- navi is written in Rust, while fzy is written in C
- navi offers a more feature-rich interface for command-line assistance
- fzy focuses on fast and simple fuzzy finding functionality
- navi has a larger community and more frequent updates
- fzy is lighter and more specialized for its specific use case
Simplistic interactive filtering tool
Pros of peco
- More feature-rich with customizable UI and keybindings
- Supports multiple selection of items
- Offers flexible output formats and filtering options
Cons of peco
- Larger codebase and potentially slower performance
- More complex setup and configuration required
- Written in Go, which may not be as universally available as C
Code Comparison
peco (Go):
func (fs *FilterSet) Add(f Filter) {
fs.filters = append(fs.filters, f)
}
fzy (C):
int match(const char *needle, const char *haystack) {
while (*needle && *haystack) {
if (tolower(*needle) == tolower(*haystack++))
needle++;
}
return *needle == '\0';
}
Summary
peco is a more feature-rich and customizable fuzzy finder, offering multiple selection and flexible output options. It's written in Go and has a larger codebase, which may impact performance. fzy, on the other hand, is a simpler, faster alternative written in C, focusing on speed and efficiency. fzy uses a more straightforward matching algorithm, while peco provides more advanced filtering capabilities. The choice between the two depends on the specific needs of the project, with peco being better suited for complex use cases and fzy for simpler, performance-critical applications.
A simple, fast and user-friendly alternative to 'find'
Pros of fd
- Written in Rust, offering better performance and memory safety
- More feature-rich, including advanced filtering options and colorized output
- Actively maintained with frequent updates and improvements
Cons of fd
- Larger binary size due to being written in Rust
- May have a steeper learning curve for users familiar with traditional Unix tools
Code Comparison
fd:
let regex = RegexBuilder::new(&pattern)
.case_insensitive(true)
.build()
.unwrap();
fzy:
int fzy_match(const char *needle, const char *haystack, int case_sensitive) {
// ... (matching logic)
}
Key Differences
- fd is a modern alternative to the
find
command, while fzy is a fuzzy finder for use in interactive selection - fd focuses on file and directory searching, whereas fzy is designed for general-purpose string matching
- fd provides a more user-friendly interface with colored output and intuitive options
- fzy is lightweight and easily integrable into other tools and scripts
Use Cases
- fd: Quickly locating files and directories in a filesystem
- fzy: Interactive selection in command-line applications or scripts
Both tools serve different purposes and can be complementary in a developer's toolkit. fd excels at file system operations, while fzy shines in interactive fuzzy matching scenarios.
ripgrep recursively searches directories for a regex pattern while respecting your gitignore
Pros of ripgrep
- Faster and more efficient for searching large codebases
- Supports advanced search features like regex and file type filtering
- Actively maintained with frequent updates and improvements
Cons of ripgrep
- More complex to use, with a steeper learning curve
- Larger installation size and more dependencies
- Not designed for fuzzy finding or interactive selection
Code comparison
ripgrep:
use grep_regex::RegexMatcher;
use grep_searcher::Searcher;
use grep_searcher::sinks::UTF8;
let matcher = RegexMatcher::new(r"foo.*bar").unwrap();
let mut searcher = Searcher::new();
searcher.search_path(&matcher, "path/to/file", UTF8(|_, line| {
println!("{}", line);
Ok(true)
})).unwrap();
fzy:
#include "fzy.h"
const char *haystack = "path/to/file";
const char *needle = "file";
double score;
score = match(haystack, needle);
if (score > 0) {
printf("Match found with score: %f\n", score);
}
Summary
ripgrep is a powerful, fast, and feature-rich search tool designed for searching large codebases, while fzy is a simpler, lightweight fuzzy finder optimized for interactive use. ripgrep excels in performance and advanced search capabilities, but may be overkill for simple fuzzy finding tasks. fzy, on the other hand, is easier to use and integrate into interactive workflows but lacks the advanced features and raw search speed of ripgrep.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
fzy is a fast, simple fuzzy text selector for the terminal with an advanced scoring algorithm.
It's been kind of life-changing. -@graygilmore
fzy works great btw -@alexblackie
Why use this over fzf, pick, selecta, ctrlp, ...?
fzy is faster and shows better results than other fuzzy finders.
Most other fuzzy matchers sort based on the length of a match. fzy tries to find the result the user intended. It does this by favouring matches on consecutive letters and starts of words. This allows matching using acronyms or different parts of the path.
A gory comparison of the sorting used by fuzzy finders can be found in ALGORITHM.md
fzy is designed to be used both as an editor plugin and on the command line. Rather than clearing the screen, fzy displays its interface directly below the current cursor position, scrolling the screen if necessary.
Installation
macOS
Using Homebrew
brew install fzy
Using MacPorts
sudo port install fzy
Arch Linux/MSYS2: pacman -S fzy
FreeBSD: pkg install fzy
Gentoo Linux: emerge -av app-shells/fzy
Ubuntu/Debian: apt-get install fzy
pkgsrc (NetBSD and others): pkgin install fzy
openSUSE: zypper in fzy
From source
make
sudo make install
The PREFIX
environment variable can be used to specify the install location,
the default is /usr/local
.
Usage
fzy is a drop in replacement for selecta, and can be used with its usage examples.
Use with Vim
fzy can be easily integrated with vim.
function! FzyCommand(choice_command, vim_command)
try
let output = system(a:choice_command . " | fzy ")
catch /Vim:Interrupt/
" Swallow errors from ^C, allow redraw! below
endtry
redraw!
if v:shell_error == 0 && !empty(output)
exec a:vim_command . ' ' . output
endif
endfunction
nnoremap <leader>e :call FzyCommand("find . -type f", ":e")<cr>
nnoremap <leader>v :call FzyCommand("find . -type f", ":vs")<cr>
nnoremap <leader>s :call FzyCommand("find . -type f", ":sp")<cr>
Any program can be used to filter files presented through fzy. ag (the silver searcher) can be used to ignore files specified by .gitignore
.
nnoremap <leader>e :call FzyCommand("ag . --silent -l -g ''", ":e")<cr>
nnoremap <leader>v :call FzyCommand("ag . --silent -l -g ''", ":vs")<cr>
nnoremap <leader>s :call FzyCommand("ag . --silent -l -g ''", ":sp")<cr>
Sorting
fzy attempts to present the best matches first. The following considerations are weighted when sorting:
It prefers consecutive characters: file
will match file over filter.
It prefers matching the beginning of words: amp
is likely to match app/models/posts.rb.
It prefers shorter matches: abce
matches abcdef over abc de.
It prefers shorter candidates: test
matches tests over testing.
See Also
- fzy.js Javascript port
Top Related Projects
:cherry_blossom: A command-line fuzzy finder
Fuzzy Finder in rust!
An interactive cheatsheet tool for the command-line
Simplistic interactive filtering tool
A simple, fast and user-friendly alternative to 'find'
ripgrep recursively searches directories for a regex pattern while respecting your gitignore
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot