summary refs log tree commit diff stats
path: root/user/modules/eshell.nix
blob: fd108af6566ad9dc4ceaa36d3555f6131ca78e81 (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,
  ...
}:
with lib; let
  cfg = config.programs.emacs;
in {
  options.programs.emacs.eshell = {
    aliases = mkOption {
      default = {};
      type = types.attrsOf types.str;
      example = {
        ll = "ls -l $*";
        ff = "find-file $1";
      };
      description = ''
        An attribute set that maps aliases (the top-level attribute names
        in this option) to command strings.
      '';
    };
  };

  config = mkIf cfg.enable {
    xdg.configFile."emacs/eshell/alias" = {
      recursive = true;
      text = concatStringsSep "\n" (mapAttrsToList (k: v: "alias ${k} ${v}") cfg.eshell.aliases);
    };
  };
}