Files-only preview on demand. Keep a preview-less default layout, and let l / h open and close the preview pane for files. The preview never opens for directories.
lon a file: open the preview panelon a directory: enter it, closing the preview if it was openh: close the preview if open, otherwise go to the parent directorytoggle-preview: one-key preview toggle, e.g. forT
While the preview is open, the parent pane is hidden (default open ratio { 0, 2, 5 }) and the linemode switches to none so the file list shows names only; closing the preview restores both.
The plugin only sets rt.mgr.ratio (it never overrides Tab.layout), so it composes with toggle-pane and the built-in layout.
ya pkg add tpsteiner/smart-paneHide the preview by default in ~/.config/yazi/yazi.toml:
[mgr]
ratio = [1, 4, 0]Register the plugin in ~/.config/yazi/init.lua (snapshots the closed layout at startup). open sets the layout while the preview is open (default { 0, 2, 5 }); linemode sets the linemode while the preview is open (default "none", pass false to keep the current one):
require("smart-pane"):setup()
-- or: require("smart-pane"):setup { open = { 1, 2, 5 }, linemode = false }Add to your ~/.config/yazi/keymap.toml:
[[mgr.prepend_keymap]]
on = "h"
run = "plugin smart-pane leave"
desc = "Close preview / go to parent dir"
[[mgr.prepend_keymap]]
on = "l"
run = "plugin smart-pane enter"
desc = "Enter dir / preview file"
[[mgr.prepend_keymap]]
on = "T"
run = "plugin smart-pane toggle-preview"
desc = "Toggle file preview"Optionally, disable directory previews entirely so the pane stays empty when a directory is hovered while the preview is open:
[plugin]
prepend_previewers = [
{ url = "*/", run = "noop" },
]This plugin is MIT-licensed. For more information check the LICENSE file.
Shoutout to sxyazi for creating toggle-pane, which this plugin is based on.