feat(shell): setup yazi file manager.

This commit is contained in:
CronyAkatsuki 2025-11-05 18:10:11 +01:00
parent cd3e60e3cc
commit b9413da4b9
3 changed files with 65 additions and 0 deletions

View file

@ -141,5 +141,51 @@
filter_mode = "directory";
};
};
# Install and setup yazi
programs.yazi = {
enable = true;
enableZshIntegration = true;
shellWrapperName = "y";
settings = {
mgr = {
ratio = [0 4 4];
sort_by = "natural";
show_hidden = true;
show_symlink = false;
};
};
plugins = {
full-border = pkgs.yaziPlugins.full-border;
smart-enter = pkgs.yaziPlugins.smart-enter;
smart-tab = ./yazi/smart-tab;
folder-rules = ./yazi/folder-rules;
};
initLua = ''
require("full-border"):setup({
type = ui.Border.ROUNDED,
})
require("smart-enter"):setup({
open_multi = true,
})
require("folder-rules"):setup()
'';
keymap = {
mgr.prepend_keymap = [
{
on = "l";
run = "plugin smart-enter";
desc = "Enter the child directory, or open the file";
}
{
on = "t";
run = "plugin smart-tab";
desc = "Create a tab and enter the howered directory";
}
];
};
};
};
}

View file

@ -0,0 +1,12 @@
local function setup()
ps.sub("cd", function()
local cwd = cx.active.current.cwd
if cwd:ends_with("downs") then
ya.emit("sort", { "mtime", reverse = true, dir_first = false })
else
ya.emit("sort", { "natural", reverse = false, dir_first = true })
end
end)
end
return { setup = setup }

View file

@ -0,0 +1,7 @@
--- @sync entry
return {
entry = function()
local h = cx.active.current.hovered
ya.emit("tab_create", h and h.cha.is_dir and { h.url } or { current = true })
end,
}