zsh: option to define autoloadable site-functions (#7611)

Add an option to the Zsh module that allows defining autoloadable site functions.
This commit is contained in:
Benedikt M. Rips 2025-08-05 21:03:10 +02:00 committed by GitHub
parent c5d7e95739
commit 36ad7d25fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 44 additions and 0 deletions

View file

@ -12,6 +12,7 @@
zsh-history-path-xdg-variable = import ./history-path.nix "xdg-variable";
zsh-history-path-zdotdir-variable = import ./history-path.nix "zdotdir-variable";
zsh-history-substring-search = ./history-substring-search.nix;
zsh-siteFunctions-mkcd = ./siteFunctions-mkcd.nix;
zsh-plugins = ./plugins.nix;
zsh-prezto = ./prezto.nix;
zsh-session-variables = ./session-variables.nix;

View file

@ -0,0 +1,17 @@
let
body = ''
mkdir --parents "$1" && cd "$1"
'';
in
{
programs.zsh = {
enable = true;
siteFunctions.mkcd = body;
};
nmt.script = ''
assertFileExists home-path/share/zsh/site-functions/mkcd
assertFileContent home-path/share/zsh/site-functions/mkcd ${builtins.toFile "mkcd" body}
assertFileContains home-files/.zshrc "autoload -Uz mkcd"
'';
}