main
  1{
  2  den.aspects.dev.yazi = {
  3    hjem = {pkgs, ...}: let
  4      auto-layout = pkgs.yaziPlugins.mkYaziPlugin {
  5        pname = "auto-layout.yazi";
  6        version = "unstable-25-07-30";
  7        src = pkgs.fetchFromGitHub {
  8          owner = "Yazelix";
  9          repo = "auto-layout.yazi";
 10          rev = "df562160ea1d86d16c83af632d0d5bb9c0a927b7";
 11          hash = "sha256-6j+bPnBTFRQshNUQIVaoeTZYhtnicaNfhTZRkururj4=";
 12        };
 13        meta = {
 14          description = "Automatically change the column layout in yazi based on available window width";
 15          homepage = "https://github.com/Yazelix/auto-layout.yazi";
 16          license = pkgs.lib.licenses.mit;
 17        };
 18      };
 19    in {
 20      packages = [pkgs.yazi];
 21
 22      programs.bash.interactiveShellInit = ''
 23        function yy() {
 24          local tmp="$(mktemp -t "yazi-cwd.XXXXX")"
 25          command yazi "$@" --cwd-file="$tmp"
 26          if cwd="$(<"$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
 27            builtin cd -- "$cwd"
 28          fi
 29          rm -f -- "$tmp"
 30        }
 31      '';
 32
 33      xdg.config.files = {
 34        "yazi/plugins/auto-layout.yazi".source = auto-layout;
 35        "yazi/plugins/clipboard.yazi".source = pkgs.yaziPlugins.clipboard;
 36        "yazi/plugins/git.yazi".source = pkgs.yaziPlugins.git;
 37
 38        "yazi/init.lua".text = ''
 39          require("auto-layout"):setup()
 40          require("git"):setup()
 41        '';
 42
 43        "yazi/yazi.toml" = {
 44          generator = (pkgs.formats.toml {}).generate "yazi-settings.toml";
 45          value = {
 46            mgr = {
 47              show_hidden = true;
 48              sort_dir_first = true;
 49            };
 50            plugin.prepend_fetchers = [
 51              {
 52                url = "*";
 53                run = "git";
 54                group = "git";
 55              }
 56              {
 57                url = "*/";
 58                run = "git";
 59                group = "git";
 60              }
 61            ];
 62          };
 63        };
 64
 65        "yazi/keymap.toml" = {
 66          generator = (pkgs.formats.toml {}).generate "yazi-keymap.toml";
 67          value = {
 68            mgr.prepend_keymap = [
 69              {
 70                on = "y";
 71                run = ["yank" "plugin clipboard -- --action=copy"];
 72                desc = "Yank selected files (copy)";
 73              }
 74              {
 75                on = "x";
 76                run = ["yank --cut" "plugin clipboard -- --action=copy"];
 77                desc = "Yank selected files (cut)";
 78              }
 79              {
 80                on = "<C-p>";
 81                run = ["plugin clipboard -- --action=paste"];
 82                desc = "Paste yanked system clipboard files";
 83              }
 84            ];
 85          };
 86        };
 87      };
 88    };
 89  };
 90
 91  den.aspects.dev.yazi.themes = {
 92    catppuccin = {
 93      hjem = {pkgs, ...}: let
 94        catppuccin-yazi = pkgs.fetchurl {
 95          url = "https://github.com/catppuccin/yazi/raw/baaf5d1c9427b836fbefd126aa855f9eab7a9d0d/themes/mocha/catppuccin-mocha-mauve.toml";
 96          hash = "sha256-MaVO1ZSjxqULH00NoY9J6hEOw9QQA2vV6saN17WF9yE=";
 97        };
 98        catppuccin-syntax = pkgs.fetchurl {
 99          name = "Catppuccin-Mocha.tmTheme";
100          url = "https://github.com/catppuccin/bat/raw/6810349b28055dce54076712fc05fc68da4b8ec0/themes/Catppuccin%20Mocha.tmTheme";
101          hash = "sha256-OVVm8IzrMBuTa5HAd2kO+U9662UbEhVT8gHJnCvUqnc=";
102        };
103      in {
104        xdg.config.files = {
105          "yazi/theme.toml".source = catppuccin-yazi;
106          "yazi/Catppuccin-mocha.tmTheme".source = catppuccin-syntax;
107        };
108      };
109    };
110  };
111}