aboutsummaryrefslogtreecommitdiff
path: root/home-manager/modules/programs/zsh.nix
diff options
context:
space:
mode:
Diffstat (limited to 'home-manager/modules/programs/zsh.nix')
-rw-r--r--home-manager/modules/programs/zsh.nix54
1 files changed, 53 insertions, 1 deletions
diff --git a/home-manager/modules/programs/zsh.nix b/home-manager/modules/programs/zsh.nix
index c5694e1f704..ed65d5fe487 100644
--- a/home-manager/modules/programs/zsh.nix
+++ b/home-manager/modules/programs/zsh.nix
@@ -18,6 +18,10 @@ let
mapAttrsToList (k: v: "alias ${k}=${lib.escapeShellArg v}") cfg.shellAliases
);
+ globalAliasesStr = concatStringsSep "\n" (
+ mapAttrsToList (k: v: "alias -g ${k}=${lib.escapeShellArg v}") cfg.shellGlobalAliases
+ );
+
zdotdir = "$HOME/" + cfg.dotDir;
bindkeyCommands = {
@@ -152,6 +156,17 @@ let
Name of the theme to be used by oh-my-zsh.
'';
};
+
+ extraConfig = mkOption {
+ default = "";
+ example = ''
+ zstyle :omz:plugins:ssh-agent identities id_rsa id_rsa2 id_github
+ '';
+ type = types.lines;
+ description = ''
+ Extra settings for plugins.
+ '';
+ };
};
};
@@ -170,6 +185,14 @@ in
type = types.nullOr types.bool;
};
+ cdpath = mkOption {
+ default = [];
+ description = ''
+ List of paths to autocomplete calls to `cd`.
+ '';
+ type = types.listOf types.str;
+ };
+
dotDir = mkOption {
default = null;
example = ".config/zsh";
@@ -183,7 +206,12 @@ in
shellAliases = mkOption {
default = {};
- example = { ll = "ls -l"; ".." = "cd .."; };
+ example = literalExample ''
+ {
+ ll = "ls -l";
+ ".." = "cd ..";
+ }
+ '';
description = ''
An attribute set that maps aliases (the top level attribute names in
this option) to command strings or directly to build outputs.
@@ -191,6 +219,21 @@ in
type = types.attrsOf types.str;
};
+ shellGlobalAliases = mkOption {
+ default = {};
+ example = literalExample ''
+ {
+ UUID = "$(uuidgen | tr -d \\n)";
+ G = "| grep";
+ }
+ '';
+ description = ''
+ Similar to <varname><link linkend="opt-programs.zsh.shellAliases">opt-programs.zsh.shellAliases</link></varname>,
+ but are substituted anywhere on a line.
+ '';
+ type = types.attrsOf types.str;
+ };
+
enableCompletion = mkOption {
default = true;
description = ''
@@ -357,6 +400,10 @@ in
home.file."${relToDotDir ".zshrc"}".text = ''
typeset -U path cdpath fpath manpath
+ ${optionalString (cfg.cdpath != []) ''
+ cdpath+=(${concatStringsSep " " cfg.cdpath})
+ ''}
+
for profile in ''${(z)NIX_PROFILES}; do
fpath+=($profile/share/zsh/site-functions $profile/share/zsh/$ZSH_VERSION/functions $profile/share/zsh/vendor-completions)
done
@@ -393,6 +440,8 @@ in
${envVarsStr}
${optionalString cfg.oh-my-zsh.enable ''
+ # oh-my-zsh extra settings for plugins
+ ${cfg.oh-my-zsh.extraConfig}
# oh-my-zsh configuration generated by NixOS
${optionalString (cfg.oh-my-zsh.plugins != [])
"plugins=(${concatStringsSep " " cfg.oh-my-zsh.plugins})"
@@ -433,6 +482,9 @@ in
# Aliases
${aliasesStr}
+
+ # Global Aliases
+ ${globalAliasesStr}
'';
}