mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19:45 +01:00
zsh-abbr: add module
This commit is contained in:
parent
4e52d9b7f7
commit
b0e0d82696
6 changed files with 73 additions and 0 deletions
|
@ -257,6 +257,12 @@
|
|||
githubId = 605641;
|
||||
name = "Bart Bakker";
|
||||
};
|
||||
ilaumjd = {
|
||||
name = "Ilham AM";
|
||||
email = "ilaumjd@gmail.com";
|
||||
github = "ilaumjd";
|
||||
githubId = 16514431;
|
||||
};
|
||||
jrobsonchase = {
|
||||
email = "josh@robsonchase.com";
|
||||
github = "jrobsonchase";
|
||||
|
|
|
@ -1258,6 +1258,14 @@ in
|
|||
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'
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -237,6 +237,7 @@ let
|
|||
./programs/zplug.nix
|
||||
./programs/zsh.nix
|
||||
./programs/zsh/prezto.nix
|
||||
./programs/zsh/zsh-abbr.nix
|
||||
./services/autorandr.nix
|
||||
./services/avizo.nix
|
||||
./services/barrier.nix
|
||||
|
|
40
modules/programs/zsh/zsh-abbr.nix
Normal file
40
modules/programs/zsh/zsh-abbr.nix
Normal 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";
|
||||
};
|
||||
};
|
||||
}
|
|
@ -8,4 +8,5 @@
|
|||
zsh-history-substring-search = ./history-substring-search.nix;
|
||||
zsh-prezto = ./prezto.nix;
|
||||
zsh-syntax-highlighting = ./syntax-highlighting.nix;
|
||||
zsh-abbr = ./zsh-abbr.nix;
|
||||
}
|
||||
|
|
17
tests/modules/programs/zsh/zsh-abbr.nix
Normal file
17
tests/modules/programs/zsh/zsh-abbr.nix
Normal 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'"
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue