Pipe any shell command as a previewer.
ya pkg add yazi-rs/plugins:piper
Piper is a general-purpose previewer - you can pass any shell command to piper and it will use the command's output as the preview content.
It accepts a string parameter, which is the shell command to be executed, for example:
# ~/.config/yazi/yazi.toml
[[plugin.prepend_previewers]]
url = "*"
run = 'piper -- echo "$1"'
This will set piper as the previewer for all file types and use $1 (file path) as the preview content.
Available variables:
$w: the width of the preview area.$h: the height of the preview area.$1: the path to the file being previewed.Here are some configuration examples:
tar[[plugin.prepend_previewers]]
url = "*.tar*"
run = 'piper --format=url -- tar tf "$1"'
In this example, --format=url tells piper to parse the tar output as file URLs, so you'll be able to get a list of files with icons.
bat[[plugin.prepend_previewers]]
url = "*.csv"
run = 'piper -- bat -p --color=always "$1"'
Note that certain distributions might use a different name for bat, like Debian and Ubuntu uses batcat instead, so please adjust accordingly.
glow[[plugin.prepend_previewers]]
url = "*.md"
run = 'piper -- CLICOLOR_FORCE=1 glow -w=$w -s=dark "$1"'
Note that there's a bug in Glow v2.0 that causes slight color differences between tty and non-tty environments.
eza[[plugin.prepend_previewers]]
url = "*/"
run = 'piper -- eza -TL=3 --color=always --icons=always --group-directories-first --no-quotes "$1"'
hexyl as fallback previewerYazi defaults to using file -bL "$1" if there's no matched previewer.
This example uses hexyl as a fallback previewer instead of file.
[[plugin.append_previewers]]
url = "*"
run = 'piper -- hexyl --border=none --terminal-width=$w "$1"'
This plugin is MIT-licensed. For more information check the LICENSE file.