fzy
is a command line fuzzy finder that allows fast search and selection of strings within a big collection. It’s a good replacement for the builtin
file completion menu in kakoune, particularly when opening files several directory levels afar from the current working directory, or looking for a file
whose location is unknown.
The script requires kakoune to have been started within a tmux
or a dvtm
session, as fzy
will be run into
a seperate pane/window whenever needed. The utils.kak
also have to have been loaded by kakoune in order for the fzy-cached
command to work.
Command to use to get a list to select from. Defaults to an ag
command (the %s
string in the variable’s value will be replaced with the path to search),
but other classical tools can be used as well, e.g. find '%s' -type f
.
Options that will be passed to fzy-tmux
or fzy-dvtm
after the candidates list has been generated/read. Defaults to -l $(tput lines)
to allow
the entire window/pane newly created to be used, as opposed to the 10 lines that fzy
uses by default.
Name of the file that contains the cached candidates that fzy
will allow the user to select from.
This function takes a list of directory paths as argument (if no argument is passed, then the current working directory of the buffer is used instead),
spawns a tmux
pane or dvtm
window containing the candidates list handled by fzy
, and then opens the selected paths as kakoune buffers. The list of candidates is
generated by running the content of the fzf_filesearch_cmd
variable, whose output will be passed unfiltered to fzy-tmux
/fzy-dvtm
.
If no path is selected (e.g. hitting ^D
in the fzy
selection menu), then no buffer is opened.
Example: opening a main.c
file located somewhere in the remote ~/work/test
directory
:fzy ~/work/test type 'main.c$' hit return on the path to select, moving up/down with the arrow keys
This function works similarly to the fzy
function, except that it will use the paths passed as arguments as starting points, and then look upward for a
file whose name is stored in the fzf_cache_filename
variable. Once that file has been found, the function feeds its content to fzy-tmux
/fzy-dvtm
to allow the
user to select entries from the list.
This function avoids spawning a process (e.g. ag
or find
) that will make a list of all the files within the directories passed as argument, which can
hurt performance very harshly when coding over a network filesystem, or in a directory containing a big amount of subdirectories.
Example: caching files for selection, and using the cache file to open a main.c
file
ag -g '' > ~/work/test/paths cd ~/work/test/some/sub/dir :fzy-cached type 'main.c$' hit return on the path to select, moving up/down with the arrow keys