From d44822d5873b435ab08e420f8ecf88cbfd5808be Mon Sep 17 00:00:00 2001 From: punkfairie Date: Sat, 16 Nov 2024 12:21:24 -0800 Subject: [PATCH] feat(home): Bat --- homes/x86_64-linux/marley@nyx/default.nix | 1 + modules/home/programs/bat/default.nix | 81 +++++++++++++++++++++++ old/home/programs/bat.nix | 69 ------------------- 3 files changed, 82 insertions(+), 69 deletions(-) create mode 100644 modules/home/programs/bat/default.nix delete mode 100644 old/home/programs/bat.nix diff --git a/homes/x86_64-linux/marley@nyx/default.nix b/homes/x86_64-linux/marley@nyx/default.nix index d9f8678..da48849 100644 --- a/homes/x86_64-linux/marley@nyx/default.nix +++ b/homes/x86_64-linux/marley@nyx/default.nix @@ -15,6 +15,7 @@ in }; programs = { amfora = enabled; + bat = enabled; fish = enabled; journalctl = enabled; neo = enabled; diff --git a/modules/home/programs/bat/default.nix b/modules/home/programs/bat/default.nix new file mode 100644 index 0000000..e1d5a6f --- /dev/null +++ b/modules/home/programs/bat/default.nix @@ -0,0 +1,81 @@ +{ + lib, + config, + namespace, + pkgs, + ... +}: +let + inherit (lib) mkIf; + inherit (lib.${namespace}) mkEnableModule enabled; + + cfg = config.${namespace}.programs.bat; + inherit (config.${namespace}) theme; +in +{ + options = mkEnableModule "programs.bat"; + + config = mkIf cfg.enable { + programs.bat = { + enable = true; + + extraPackages = with pkgs.bat-extras; [ + batdiff + batman + ]; + + "${theme.colors.base}" = enabled; + + config = { + style = "auto"; + }; + }; + + home.sessionVariables = lib.mkIf config.programs.git.delta.enable { + BATDIFF_USE_DELTA = "true"; + }; + + programs.fish = lib.mkIf config.programs.fish.enable { + functions = { + cat = { + wraps = "bat"; + body = # fish + "bat $argv"; + }; + + cath = { + wraps = "bat"; + body = # fish + "bat --plain --language=help $argv"; + }; + }; + }; + + home.shellAbbrs = { + B = { + position = "anywhere"; + setCursor = true; + expansion = # fish + "% | bat"; + }; + + "-h" = { + position = "anywhere"; + expansion = # fish + "-h | cath"; + }; + + "--help" = { + position = "anywhere"; + expansion = # fish + "--help | cath"; + }; + + help = { + position = "anywhere"; + expansion = # fish + "help | cath"; + }; + }; + }; +} diff --git a/old/home/programs/bat.nix b/old/home/programs/bat.nix deleted file mode 100644 index 9213c93..0000000 --- a/old/home/programs/bat.nix +++ /dev/null @@ -1,69 +0,0 @@ -{ - pkgs, - config, - lib, - ... -}: -{ - programs.bat = { - enable = true; - - extraPackages = with pkgs.bat-extras; [ - batdiff - batman - ]; - - rose-pine.enable = true; - - config = { - style = "auto"; - }; - }; - - home.sessionVariables = lib.mkIf config.home.preferXdgDirectories { - BATDIFF_USE_DELTA = "true"; - }; - - programs.fish = lib.mkIf config.programs.fish.enable { - functions = { - cat = { - wraps = "bat"; - body = # fish - "bat $argv"; - }; - - cath = { - wraps = "bat"; - body = # fish - "bat --plain --language=help $argv"; - }; - }; - - shellAbbrs = { - B = { - position = "anywhere"; - setCursor = true; - expansion = # fish - "% | bat"; - }; - - "-h" = { - position = "anywhere"; - expansion = # fish - "-h | cath"; - }; - - "--help" = { - position = "anywhere"; - expansion = # fish - "--help | cath"; - }; - - help = { - position = "anywhere"; - expansion = # fish - "help | cath"; - }; - }; - }; -}