diff options
Diffstat (limited to 'modules/terminal/fzf')
| -rw-r--r-- | modules/terminal/fzf/assertions.nix | 13 | ||||
| -rw-r--r-- | modules/terminal/fzf/default.nix | 51 |
2 files changed, 64 insertions, 0 deletions
diff --git a/modules/terminal/fzf/assertions.nix b/modules/terminal/fzf/assertions.nix new file mode 100644 index 0000000..7c2e79c --- /dev/null +++ b/modules/terminal/fzf/assertions.nix @@ -0,0 +1,13 @@ +{ config, ... }: +{ + assertions = [ + { + assertion = + !config.programs.fzf.enable || config.programs.zsh.enable || config.programs.bash.enable; + message = '' + programs.fzf is enabled but neither programs.zsh.enable nor programs.bash.enable is set. + fzf shell integration requires zsh or bash. Please enable at least one. + ''; + } + ]; +} diff --git a/modules/terminal/fzf/default.nix b/modules/terminal/fzf/default.nix new file mode 100644 index 0000000..7671b3c --- /dev/null +++ b/modules/terminal/fzf/default.nix @@ -0,0 +1,51 @@ +{ config, lib, ... }: + +# FZF - Fuzzy finder, CLI fuzzy search tool +{ + imports = [ ./assertions.nix ]; + + config = + let + shellIntegration = '' + ${if config.programs.zsh.enable then "eval \"$(fzf --zsh)\"" else "eval \"$(fzf --bash)\""} + ''; + in + lib.mkIf config.programs.fzf.enable { + programs.fzf = { + defaultOptions = [ + "--height 100%" + "--layout=reverse" + ''--pointer=\" \"'' + ''--header=\" \"'' + ''--prompt=\" \"'' + ''--marker=\"✓ \"'' + "--border=none" + "--cycle" + "--no-info" + "--margin=\"1,2\"" + ]; + + colors = with config.scheme.withHashtag; { + fg = base05; # Foreground + bg = "-1"; # Background (-1 for transparent) + hl = base0D; # Highlight + + "fg+" = base07; # Foreground for selected item + "bg+" = "-1"; # Background for selected item + "hl+" = base0D; # Highlight for selected item + + gutter = "-1"; # Remove the white margin at the left + + info = base0B; # Info text (usually count of items) + border = base03; # Border color + prompt = base0A; # Prompt text color + pointer = base0F; # Pointer color (e.g., > for selected) + marker = base0C; # Marker color (e.g., for multi-select) + spinner = base0C; # Spinner color (during search) + }; + }; + + programs.zsh.initContent = lib.mkIf config.programs.zsh.enable (lib.mkAfter shellIntegration); + programs.bash.initExtra = lib.mkIf config.programs.bash.enable (lib.mkAfter shellIntegration); + }; +} |
