about summary refs log tree commit diff
path: root/modules/common/bat.nix
blob: 2b31d1651f96cdc4821c6a8e6de13ccb9c7486e1 (plain) (blame)
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
{
  config,
  lib,
  pkgs,
  ...
}:
with lib; let
  cfg = config.nixfiles.modules.bat;
in {
  options.nixfiles.modules.bat.enable =
    mkEnableOption "bat, an alternative to cat";

  config = mkIf cfg.enable {
    hm.programs = {
      bat = {
        enable = true;
        config = {
          style = "plain";
          tabs = "4";
          theme = "base16";
          wrap = "never";
        };
      };

      bash = {
        shellAliases = let
          bat = "${pkgs.bat}/bin/bat";
        in {
          bay = "${bat} --language=yaml --tabs 2";
          baj = "${bat} --language=json --tabs 2";
        };

        initExtra = mkAfter ''
          _complete_alias bay _bat bat
          _complete_alias baj _bat bat
        '';
      };
    };
  };
}

Consider giving Nix/NixOS a try! <3