fazif allows you to search over selected items in Yazi with your configuration of search and fuzzy filter command.
You can config search command (fd, rg, rga, ag, astgrep ...), fuzzy filter command (fzf, fzy, zf, skim), and options in a script and spawn all your scripts easily into yazi. Here are some use cases.
- Search within the current working directory when none are selected.
For example, a simple directory jumper. Simply create a file in ~/.config/yazi/plugins/fazif.yazi with one of the following, make it executable, and set a keybinding.
#!/usr/bin/env zsh
fd -H -t d|fzf
or
#!/usr/bin/env zsh
fd -H -t d|zf
or jump to a dir. outside CWD by applying your query to a upper dir. with a shortcut key.
#!/usr/bin/env zsh
fd -H -t d|fzf \
--bind 'ctrl-e:transform:echo "change-prompt(Home_Dir> )+reload(fd . ~ --hidden --type d)"' \
- Search within selected files and directories
Example 1: to jump to some dir. in the selected folders, simply create a file in ~/.config/yazi/plugins/fazif.yazi with one of the following, make it executable, and set a keybinding.
#!/usr/bin/env zsh
fd -H -t d "$@"|fzf
or
#!/usr/bin/env zsh
fd -H -t d "$@"|zf
Example 2: use fazifrga script to search for a pattern in selected PDFs and preview the matching pages that have the pattern with fzf.
- Reveal the selected file or enter the selected directory in a new yazi tab; if multiple items are selected in fzf (using the
-multioption in fzf), then show the selected items in the search result view.
For example, find relevant books using faziffd and reveal them in yazi's search result view, then use fazifrga to search for a pattern in these books.
- show recent modified files.
#!/usr/bin/env zsh
fd -H -t f --changed-within 1d|fzf
This plugin acts as a bridge between Yazi and standalone scripts. The main.lua file serves as a generic wrapper that:
- Passes the current working directory and selected files/directories from Yazi (
"$@"in the script) to the script - Executes the specified script (passed as an argument in the keymap)
- Send results in Yazi search pane if multiple selected or reveal/enter the selected item in a yazi new tab
- Install via ya:
ya pkg -a Shallow-Seek/fazifor
git clone https://github.com/Shallow-Seek/fazif.yazi.git ~/.config/yazi/plugins/fazif.yazi- The 3 default scripts
faziffd,fazifrg, andfazifrgaprovided are examples with features shown in the next section. The plugin still works with your scripts without them.
Simple put your script in ~/.config/yazi/plugins/fazif.yazi and set a keybinding to use them. To make your script search on selected items, just add "$@" to the search command. Check faziffd to see that.
Also you need change your rg or rga's delimiter to U+00A0 by adding the option --field-match-separator $'\u00a0'
to your rg or rga commmand and --delimiter $'\u00a0' option to fzf. See the default fazifrg as an example.
but you can modify the following line in main.lua to use your prefered delimiter.
local file = line:find("\xC2\xA0") and line:sub(1, line:find("\xC2\xA0") - 1) or lineUTF-8 encoding of
U+00A0is\xC2\xA0
Make sure your scripts are executable:
chmod +x ~/.config/yazi/plugins/fazif.yazi/faziffd
chmod +x ~/.config/yazi/plugins/fazif.yazi/fazifrg
chmod +x ~/.config/yazi/plugins/fazif.yazi/fazifrga
chmod +x ~/.config/yazi/plugins/fazif.yazi/yourscript1
...You may need to update the shebang (#!) in the example scripts.
The plugin can be configured to run any of your scripts by passing the script name as an argument. Add the following to your ~/.config/yazi/keymap.toml to bind each script to a key combination:
# File/Directory finder using fd + fzf
[[mgr.prepend_keymap]]
on = [ "b", "d" ]
run = "plugin fazif faziffd"
desc = "Find files/directories with fd and fzf"
# Content finder using ripgrep + fzf
[[mgr.prepend_keymap]]
on = [ "b", "r" ]
run = "plugin fazif fazifrg"
desc = "Find content in files with ripgrep and fzf"
# Document content finder using ripgrep-all + fzf
[[mgr.prepend_keymap]]
on = [ "b", "a" ]
run = "plugin fazif fazifrga"
desc = "Find content in documents with ripgrep-all and fzf"
...That's it. is not the default :, you will need to change the delimiter in main.lua.
Read this section if you use the default scripts faziffd, fazifrg, and fazifrga.
- faziffd - File/directory jumper using
fd. Txt preview withbatand Directory preview witheza - fazifrg -
ripgrepon selected. Preview shows file content withbatwhen started with no input. With any input,rgkicks in, and the preview highlights the matching line. - fazifrga -
ripgrep-allsearch in selected PDFs and DjVu. Preview shows the first page of a document when started with no input. With any input,rgakicks in, and the preview shows the matching page in the document.
The 3 scripts use the following tools:
- fzf
- fd - Used by
faziffd - ripgrep - Used by
fazifrg - ripgrep-all - Used by
fazifrga - rga djvu adaptor - Used by
fazifrgato search in djvu - Additional tools for document previews:
- kitty Image preview uses kitty icat. You can also use other terminals that support image or use ueberzugpp.
- bat - Used by
faziffd,fazifrg - eza - Used by
faziffd pdftoppmfrom poppler-utils - Used byfaziffd,fazifrgafor pdf prevew.ddjvufrom djvulibre - Used byfaziffd,fazifrgafor djvu preview.- libreoffice for office documents - Used by
faziffdfor office file preview.
Ctrl-w: Search files in the home directoryCtrl-e: Search directories in the home directoryAlt-c: Search directories in the current working directoryCtrl-t: Search files in the current working directoryCtrl-f: Search directories from the rootCtrl-p: Toggle the preview window/positionCtrl-x: Open in Yazi (new instance)(ifsetsidis not available, usenohup)
Ctrl-y: Switch between rga search mode and fzf filtering modeCtrl-p: Toggle the preview window/positionCtrl-o:fazifrgopen file in Neovim at the matched line.fazifrgaopen document in Zathura at the matched page and highlight the query.
This plugin is released under the MIT License.
Plugin is based on the default Yazi fzf plugin and vcs-files plugin. Fzf scripts grow out of fzf's wiki and examples.