Skip to content
/ fzy Public template
forked from jhawthorn/fzy

A fork of fzy with multi-selection, color support, and a few more things. Consult the manpage (fzy.1) for details.

License

Notifications You must be signed in to change notification settings

leo-arch/fzy

 
 

Repository files navigation

fzy

fzy is a fast, simple fuzzy text selector for the terminal with an advanced scoring algorithm.

Disclaimer: This fork (originaly intended to make fzy work with the clifm file manager) adds a few new features to the origianl fzy, including basic color support and multi-selection. Consult the manpage for more information.

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

mkdir build && cd build
git clone https://github.com/leo-arch/fzy
cd fzy
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>

Use with clifm

Just run clifm as follows:

clifm --fzytab

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.

About

A fork of fzy with multi-selection, color support, and a few more things. Consult the manpage (fzy.1) for details.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 76.0%
  • Ruby 14.6%
  • Roff 5.1%
  • Shell 2.4%
  • Makefile 1.9%