fork/home-manager

git clone https://git.julia.blue/fork/home-manager

ilaumjdzsh-abbr: add moduleb0e0d826

master
1.0 KiB40 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4let cfg = config.programs.zsh.zsh-abbr;
5in {
6  meta.maintainers = [ hm.maintainers.ilaumjd ];
7
8  options.programs.zsh.zsh-abbr = {
9    enable =
10      mkEnableOption "zsh-abbr - zsh manager for auto-expanding abbreviations";
11
12    abbreviations = mkOption {
13      type = types.attrsOf types.str;
14      default = { };
15      example = {
16        l = "less";
17        gco = "git checkout";
18      };
19      description = ''
20        An attribute set that maps aliases (the top level attribute names
21        in this option) to abbreviations. Abbreviations are expanded with
22        the longer phrase after they are entered.
23      '';
24    };
25  };
26
27  config = mkIf cfg.enable {
28    programs.zsh.plugins = [{
29      name = "zsh-abbr";
30      src = pkgs.zsh-abbr;
31      file = "/share/zsh/zsh-abbr/abbr.plugin.zsh";
32    }];
33
34    xdg.configFile = {
35      "zsh-abbr/user-abbreviations".text = concatStringsSep "\n"
36        (mapAttrsToList (k: v: "abbr ${escapeShellArg k}=${escapeShellArg v}")
37          cfg.abbreviations) + "\n";
38    };
39  };
40}