nix/homes/modules/programs/yazi/yazi.nix
2026-02-12 18:53:24 +00:00

86 lines
2.7 KiB
Nix

{ config, inputs, lib, pkgs, ... }:
{
# optional dependencies can be found here:
# https://yazi-rs.github.io/docs/installation/
home.packages = with pkgs; [ # dependencies
ripdrag
];
programs.yazi = {
enable = true;
enableZshIntegration = false; # i mod"if"ied the script in my .zshrc
settings = {
mgr = {
show_hidden = true;
};
log = {
enabled = false;
};
};
keymap = {
mgr.prepend_keymap = [
# drag and drop!!
{ on = [ "<S-c>" ]; run = ''shell "ripdrag -x -a \"$@\"" --confirm''; }
# copy hovered file to clipboard
{ on = [ "<S-y>" ]; run = ''shell -- path=%h; echo "file://$path" | wl-copy -t text/uri-list''; }
];
};
# they changed it to custom colors, i don't like that, so this is the config
# i did like:
# https://github.com/sxyazi/yazi/blob/97d0c6bb23df413f4add8b888071233c912c49a3/yazi-config/preset/theme-dark.toml
theme = {
icon = {
dirs = [
{ name = ".config"; text = ""; fg = "red"; }
{ name = ".git"; text = ""; fg = "blue"; }
{ name = ".github"; text = ""; fg = "blue"; }
{ name = ".npm"; text = ""; fg = "blue"; }
{ name = "Desktop"; text = ""; fg = "magenta"; }
{ name = "Documents"; text = ""; fg = "magenta"; }
{ name = "Downloads"; text = ""; fg = "red"; }
{ name = "Library"; text = ""; fg = "magenta"; }
{ name = "Movies"; text = ""; fg = "magenta"; }
{ name = "Music"; text = ""; fg = "magenta"; }
{ name = "Pictures"; text = ""; fg = "magenta"; }
{ name = "Public"; text = ""; fg = "magenta"; }
{ name = "Videos"; text = ""; fg = "red"; }
];
conds = [
# special files
{ "if" = "orphan"; text = ""; }
{ "if" = "link"; text = ""; }
{ "if" = "block"; text = ""; }
{ "if" = "char"; text = ""; }
{ "if" = "fifo"; text = ""; }
{ "if" = "sock"; text = ""; }
{ "if" = "sticky"; text = ""; }
{ "if" = "dummy"; text = ""; }
# fallback
{ "if" = "dir"; text = ""; fg = "blue"; }
{ "if" = "exec"; text = ""; }
{ "if" = "!dir"; text = ""; }
];
};
};
};
# helped me fix it not working:
# https://github.com/hunkyburrito/xdg-desktop-portal-termfilechooser/issues/56
# also, the portal must be enabled in configuration.nix
# i can't seem to get it working any other way
xdg.configFile."xdg-desktop-portal-termfilechooser/config" = {
force = true;
text = ''
[filechooser]
cmd=${pkgs.xdg-desktop-portal-termfilechooser}/share/xdg-desktop-portal-termfilechooser/yazi-wrapper.sh
default_dir=$HOME
env=TERMCMD='kitty --title filechooser'
open_mode=suggested
save_mode=last
'';
};
}