all repos — nixfiles @ 3b28e38df728c725183f9def3b4fa26a5566b8c4

System and user configuration, managed by nix and home-manager

Emacs: create eshell module to handle aliases

Alan Pearce
commit

3b28e38df728c725183f9def3b4fa26a5566b8c4

parent

ab0e8c29b11cb35e164ff3be5eb50fee74a92644

2 files changed, 61 insertions(+), 4 deletions(-)

jump to
A 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); + }; + }; +}
M user/settings/emacs.nixuser/settings/emacs.nix
@@ -31,8 +31,40 @@ '';
}; in { + imports = [ + ../modules/eshell.nix + ]; programs.emacs = { enable = true; + eshell = { + aliases = { + pk = "eshell-up-pk $1"; + up = "eshell-up $1"; + + ec = "find-file $1"; + + l = "ls $*"; + la = "ls -A $*"; + ll = "ls -lh $*"; + lla = "ls -lhA $*"; + + https = "http --default-scheme https $*"; + + ava = "npx ava $*"; + bunyan = "npx bunyan $*"; + mocha = "npx mocha $*"; + prettier = "prettier_d --pkg-conf $*"; + standard = "npx standard $*"; + tsc = "npx tsc $*"; + tslnt = "npx tslnt $*"; + tsnode = "npx tsnode $*"; + + kx = "kubectx $*"; + kns = "kubens $*"; + + cdg = "cd (projectile-project-root)"; + }; + }; extraPackages = epkgs: (with epkgs; [ ace-link all-the-icons
@@ -135,6 +167,7 @@ wgrep-ag
ws-butler which-key yaml-mode + yasnippet ] ++ lib.optionals (!stdenv.isDarwin) [ pkgs.mu ]);
@@ -150,10 +183,6 @@ source = ../emacs/.emacs.d/init.el;
onChange = '' ${config.programs.emacs.finalPackage}/bin/emacs -Q -batch -f batch-byte-compile .emacs.d/init.el ''; - }; - home.file.".emacs.d/eshell/" = { - recursive = true; - source = ../emacs/.emacs.d/eshell; }; home.file.".local/share/applications/emacsclient.desktop".source = desktopApplicationFile;