From 3981482362931c995bc814c3e4441628b86980f1 Mon Sep 17 00:00:00 2001 From: Collin Williams <96917990+bluedragon1221@users.noreply.github.com> Date: Mon, 9 Jun 2025 20:24:27 +0000 Subject: broot is quick! --- modules/terminal/system/default.nix | 1 + modules/terminal/system/programs/broot.nix | 28 ++++++++++++++++++++++++++++ modules/terminal/system/programs/fish.nix | 26 ++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 modules/terminal/system/programs/broot.nix diff --git a/modules/terminal/system/default.nix b/modules/terminal/system/default.nix index d5cd1f5..b31fe90 100644 --- a/modules/terminal/system/default.nix +++ b/modules/terminal/system/default.nix @@ -14,6 +14,7 @@ in { ./programs/lazygit.nix ./programs/starship.nix ./programs/tmux.nix + ./programs/broot.nix ]; programs.command-not-found.enable = false; # broken without nix-channels diff --git a/modules/terminal/system/programs/broot.nix b/modules/terminal/system/programs/broot.nix new file mode 100644 index 0000000..ed86822 --- /dev/null +++ b/modules/terminal/system/programs/broot.nix @@ -0,0 +1,28 @@ +{ + pkgs, + config, + lib, + ... +}: let + cfg = config.collinux.terminal.shells.fish; + toml' = pkgs.formats.toml {}; + + conf = toml'.generate "conf.toml" { + verbs = [ + { + invocation = "edit"; + key = "enter"; + execution = "${pkgs.helix}/bin/hx {file}"; + } + ]; + }; +in + lib.mkIf cfg.enable { + hjem.users."${config.collinux.user.name}" = { + files = { + ".config/broot/conf.toml".source = conf; + }; + + packages = [pkgs.broot]; + }; + } diff --git a/modules/terminal/system/programs/fish.nix b/modules/terminal/system/programs/fish.nix index 89d26ef..7501251 100644 --- a/modules/terminal/system/programs/fish.nix +++ b/modules/terminal/system/programs/fish.nix @@ -6,6 +6,14 @@ }: let cfg = config.collinux.terminal.shells.fish; + scripts.cool-cd = pkgs.writeShellScriptBin "cd.sh" '' + if git rev-parse --is-inside-work-tree; then + cd $(fd . "$(git rev-parse --show-toplevel)" --type dir | fzf) + else + cd $(fd . --type dir | fzf) + fi + ''; + init = pkgs.writeText "config.fish" '' set fish_greeting @@ -13,6 +21,20 @@ ${pkgs.starship}/bin/starship module character end + function cool-cd + if git rev-parse --is-inside-work-tree &>/dev/null + set dirs (fd . (git rev-parse --show-toplevel) --type dir) + else + set dirs (fd . --type dir) + end + + if test -z "$dirs" + exit + end + + cd (echo "$dirs" | fzf) + end + if status is-interactive alias cat bat @@ -22,6 +44,10 @@ ${pkgs.fzf}/bin/fzf --fish | source ${pkgs.starship}/bin/starship init fish | source + ${pkgs.broot}/bin/broot --print-shell-function fish | source + + # extra bindings + bind 'alt-c' cool-cd enable_transience -- cgit v1.3.1