summaryrefslogtreecommitdiffstats
path: root/nixos/modules/programs/bash/ls-colors.nix
blob: 8d4781e3c8d030d541fe0a594327d3167ec16d05 (plain)
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
{
  config,
  lib,
  pkgs,
  ...
}:

let
  enable = config.programs.bash.enableLsColors;
in
{
  options = {
    programs.bash.enableLsColors = lib.mkEnableOption "extra colors in directory listings" // {
      default = true;
    };
    programs.bash.lsColorsFile = lib.mkOption {
      type = lib.types.nullOr lib.types.path;
      default = null;
      example = lib.literalExpression "\${pkgs.dircolors-solarized}/ansi-dark";
      description = "Alternative colorscheme for ls colors";
    };
  };

  config = lib.mkIf enable {
    programs.bash.promptPluginInit = ''
      eval "$(${pkgs.coreutils}/bin/dircolors -b ${
        lib.optionalString (config.programs.bash.lsColorsFile != null) config.programs.bash.lsColorsFile
      })"
    '';
  };
}