1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-26 03:39:47 +01:00

zsh-abbr: add module

This commit is contained in:
ilaumjd 2023-10-03 07:34:46 +07:00 committed by Mikilio
parent d97a443864
commit 8a209007e2
No known key found for this signature in database
GPG key ID: 5B2F1A890CF33F3F
6 changed files with 73 additions and 0 deletions

View file

@ -257,6 +257,12 @@
githubId = 605641; githubId = 605641;
name = "Bart Bakker"; name = "Bart Bakker";
}; };
ilaumjd = {
name = "Ilham AM";
email = "ilaumjd@gmail.com";
github = "ilaumjd";
githubId = 16514431;
};
jrobsonchase = { jrobsonchase = {
email = "josh@robsonchase.com"; email = "josh@robsonchase.com";
github = "jrobsonchase"; github = "jrobsonchase";

View file

@ -1258,6 +1258,14 @@ in
A new module is available: 'programs.khard'. A new module is available: 'programs.khard'.
''; '';
} }
{
time = "2023-10-04T06:06:08+00:00";
condition = config.programs.zsh.enable;
message = ''
A new module is available: 'programs.zsh.zsh-abbr'
'';
}
]; ];
}; };
} }

View file

@ -237,6 +237,7 @@ let
./programs/zplug.nix ./programs/zplug.nix
./programs/zsh.nix ./programs/zsh.nix
./programs/zsh/prezto.nix ./programs/zsh/prezto.nix
./programs/zsh/zsh-abbr.nix
./services/autorandr.nix ./services/autorandr.nix
./services/avizo.nix ./services/avizo.nix
./services/barrier.nix ./services/barrier.nix

View file

@ -0,0 +1,40 @@
{ config, lib, pkgs, ... }:
with lib;
let cfg = config.programs.zsh.zsh-abbr;
in {
meta.maintainers = [ hm.maintainers.ilaumjd ];
options.programs.zsh.zsh-abbr = {
enable =
mkEnableOption "zsh-abbr - zsh manager for auto-expanding abbreviations";
abbreviations = mkOption {
type = types.attrsOf types.str;
default = { };
example = {
l = "less";
gco = "git checkout";
};
description = ''
An attribute set that maps aliases (the top level attribute names
in this option) to abbreviations. Abbreviations are expanded with
the longer phrase after they are entered.
'';
};
};
config = mkIf cfg.enable {
programs.zsh.plugins = [{
name = "zsh-abbr";
src = pkgs.zsh-abbr;
file = "/share/zsh/zsh-abbr/abbr.plugin.zsh";
}];
xdg.configFile = {
"zsh-abbr/user-abbreviations".text = concatStringsSep "\n"
(mapAttrsToList (k: v: "abbr ${escapeShellArg k}=${escapeShellArg v}")
cfg.abbreviations) + "\n";
};
};
}

View file

@ -8,4 +8,5 @@
zsh-history-substring-search = ./history-substring-search.nix; zsh-history-substring-search = ./history-substring-search.nix;
zsh-prezto = ./prezto.nix; zsh-prezto = ./prezto.nix;
zsh-syntax-highlighting = ./syntax-highlighting.nix; zsh-syntax-highlighting = ./syntax-highlighting.nix;
zsh-abbr = ./zsh-abbr.nix;
} }

View file

@ -0,0 +1,17 @@
{ ... }:
{
programs.zsh.zsh-abbr = {
enable = true;
abbreviations = { ga = "git add"; };
};
test.stubs.zsh-abbr = { };
nmt.script = ''
abbreviations=home-files/.config/zsh-abbr/user-abbreviations
assertFileExists $abbreviations
assertFileContains $abbreviations "abbr 'ga'='git add'"
'';
}