aboutsummaryrefslogtreecommitdiff
path: root/modules/terminal/hjem/programs/broot.nix
blob: cd425bdcdc7749320ced301a1da4e473a4d0b41b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
{
  pkgs,
  config,
  lib,
  ...
}: let
  cfg = config.collinux.terminal.programs.broot;

  conf = {
    imports =
      if config.collinux.theme == "catppuccin"
      then ["skins/catppuccin-mocha.hjson"]
      else ["skins/dark-gruvbox.hjson"];

    default_flags = "-g";
    icon_theme = "nerdfont";
    special_paths = {
      "~/ganymede" = {
        show = "never";
        list = "never";
        sum = "never";
      };
      "~/.config".show = "always";
    };

    verbs = [
      {
        name = "edit";
        key = "enter";
        invocation = "e";
        execution = "$EDITOR +{line} {file}";
        working_dir = "{root}";
        apply_to = "file";
        leave_broot = false;
      }
      {
        name = "touch";
        invocation = "touch {filename}";
        execution = "touch {filename}";
        working_dir = "{directory}";
        apply_to = "directory";
        leave_broot = false;
      }
      {
        name = "lazygit";
        key = "ctrl-g";
        invocation = "lazygit";
        execution = "lazygit";
        working_dir = "{root}";
        leave_broot = false;
      }
      {
        invocation = "opencode {extraargs}";
        execution = "opencode {extraargs}";
        working_dir = "{root}";
        leave_broot = false;
      }
      {
        name = "justfile";
        key = "ctrl-j";
        execution = "just --choose";
        working_dir = "{root}";
        leave_broot = false;
      }
      {
        name = "terminal";
        key = "ctrl-t";
        execution = "$SHELL";
        working_dir = "{root}";
        leave_broot = false;
      }
      {
        key = "alt-enter";
        execution = "swaymsg exec -- foot -D '{root}' fish -c 'br'";
        leave_broot = false;
      }
      {
        key = "ctrl-a";
        internal = "toggle_stage";
      }
      {
        key = "ctrl-h";
        cmd = ":input_clear;:focus ~";
      }
    ];
  };
in
  lib.mkIf cfg.enable {
    files =
      {
        ".config/broot/conf.hjson" = {
          generator = (pkgs.formats.json {}).generate "broot-conf.hjson";
          value = conf;
        };
      }
      // (lib.optionalAttrs config.collinux.terminal.shells.fish.enable {
        ".config/fish/conf.d/broot.fish".text = ''
          broot --print-shell-function fish | source
        '';
      })
      // (lib.optionalAttrs config.collinux.terminal.shells.bash.enable {
        ".config/bash/conf.d/broot.bash".text = ''
          eval "$(broot --print-shell-function bash)"
        '';
      });

    packages = [pkgs.broot];
  }