diff options
| author | Collin Williams <96917990+bluedragon1221@users.noreply.github.com> | 2026-07-15 06:54:33 -0500 |
|---|---|---|
| committer | Collin Williams <96917990+bluedragon1221@users.noreply.github.com> | 2026-07-15 06:54:33 -0500 |
| commit | 8b990276c5e9abccd772694b1f7232d8b49b634c (patch) | |
| tree | 23f4c3713c538f435354270de2005475c50955d0 /modules/common/findFile.nix | |
initial commit
Diffstat (limited to 'modules/common/findFile.nix')
| -rw-r--r-- | modules/common/findFile.nix | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/modules/common/findFile.nix b/modules/common/findFile.nix new file mode 100644 index 0000000..3d08603 --- /dev/null +++ b/modules/common/findFile.nix @@ -0,0 +1,66 @@ +{ + pkgs, + config, + lib, + tsunamiLib, + std, + ... +}: let + inherit (tsunamiLib) scriptPath filePath; + cfg = config.tsunami.findFile; +in { + options = { + tsunami.findFile = { + enable = lib.mkOption { + type = lib.types.bool; + default = false; + }; + }; + }; + + config = lib.mkIf cfg.enable { + tsunami.keys.leader = [ + { + name = "Find File"; + key = "C-f"; + exec = ''run-shell "${scriptPath "minibuffer"} -d '#{?@default-path,#{@default-path},#{pane_current_path}}' '${scriptPath "find-file"}'"''; + } + ]; + tsunami.scripts = { + "minibuffer" = '' + window_height="$(tmux display -p '#{window_height}')" + tmux display-popup -EB \ + -w 100% -h 16 \ + -x 0 -y "$(($window_height + 1))" \ + "$@" + ''; + + "find-file" = ''${pkgs.broot}/bin/broot --conf ${filePath "broot_find_file.toml"}''; + }; + + tsunami.files."broot_find_file.toml" = std.serde.toTOML { + imports = ["~/.config/broot/conf.hjson"]; + quit_on_last_cancel = true; + verbs = [ + { + invocation = "tmux-split"; + external = ["bash" "-c" ''${scriptPath "split"} -c "#{?@default-path,#{@default-path},#{pane_current_path}}" "$EDITOR '{file}'"'']; + key = "ctrl-s"; + apply_to = "file"; + leave_broot = true; + } + { + invocation = "tmux-window"; + external = ["tmux" "new-window" "-c" "#{?@default-path,#{@default-path},#{pane_current_path}}" "$EDITOR '{file}'"]; + key = "ctrl-w"; + apply_to = "file"; + leave_broot = true; + } + { + key = "enter"; + cmd = ":tmux-window"; + } + ]; + }; + }; +} |
