summary refs log tree commit diff stats
path: root/user/modules
diff options
context:
space:
mode:
authorAlan Pearce2019-12-06 11:19:53 +0100
committerAlan Pearce2019-12-06 11:19:53 +0100
commit3b28e38df728c725183f9def3b4fa26a5566b8c4 (patch)
treeaa5bd5be69e2750e1011bc3585c3289e055fc63c /user/modules
parentab0e8c29b11cb35e164ff3be5eb50fee74a92644 (diff)
downloadnixfiles-3b28e38df728c725183f9def3b4fa26a5566b8c4.tar.lz
nixfiles-3b28e38df728c725183f9def3b4fa26a5566b8c4.tar.zst
nixfiles-3b28e38df728c725183f9def3b4fa26a5566b8c4.zip
Emacs: create eshell module to handle aliases
Diffstat (limited to 'user/modules')
-rw-r--r--user/modules/eshell.nix28
1 files changed, 28 insertions, 0 deletions
diff --git a/user/modules/eshell.nix b/user/modules/eshell.nix
new file mode 100644
index 00000000..c4fc366f
--- /dev/null
+++ b/user/modules/eshell.nix
@@ -0,0 +1,28 @@
+{ 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 {
+    home.file.".emacs.d/eshell/alias" = {
+      recursive = true;
+      text = concatStringsSep "\n" (mapAttrsToList (k: v: "alias ${k} ${v}") cfg.eshell.aliases);
+    };
+  };
+}