2017-08-15 13:54:33 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.programs.zsh;
|
|
|
|
|
2017-09-12 20:01:02 +02:00
|
|
|
relToDotDir = file: (optionalString (cfg.dotDir != null) (cfg.dotDir + "/")) + file;
|
|
|
|
|
|
|
|
pluginsDir = if cfg.dotDir != null then
|
|
|
|
relToDotDir "plugins" else ".zsh/plugins";
|
|
|
|
|
2018-12-13 15:23:27 +01:00
|
|
|
envVarsStr = config.lib.zsh.exportAll cfg.sessionVariables;
|
2018-12-13 15:25:09 +01:00
|
|
|
localVarsStr = config.lib.zsh.defineAll cfg.localVariables;
|
2017-09-18 00:26:42 +02:00
|
|
|
|
|
|
|
aliasesStr = concatStringsSep "\n" (
|
2024-02-22 17:55:26 +01:00
|
|
|
mapAttrsToList (k: v: "alias -- ${lib.escapeShellArg k}=${lib.escapeShellArg v}") cfg.shellAliases
|
2017-09-18 00:26:42 +02:00
|
|
|
);
|
|
|
|
|
2020-10-27 12:46:26 +01:00
|
|
|
dirHashesStr = concatStringsSep "\n" (
|
|
|
|
mapAttrsToList (k: v: ''hash -d ${k}="${v}"'') cfg.dirHashes
|
|
|
|
);
|
|
|
|
|
2024-02-19 00:00:56 +01:00
|
|
|
zdotdir = "$HOME/" + lib.escapeShellArg cfg.dotDir;
|
2017-09-12 20:01:02 +02:00
|
|
|
|
2018-12-16 15:23:08 +01:00
|
|
|
bindkeyCommands = {
|
|
|
|
emacs = "bindkey -e";
|
|
|
|
viins = "bindkey -v";
|
|
|
|
vicmd = "bindkey -a";
|
|
|
|
};
|
|
|
|
|
2019-10-28 11:11:44 +01:00
|
|
|
stateVersion = config.home.stateVersion;
|
|
|
|
|
2018-01-12 17:23:58 +01:00
|
|
|
historyModule = types.submodule ({ config, ... }: {
|
2017-08-23 12:51:54 +02:00
|
|
|
options = {
|
2024-08-23 13:29:12 +02:00
|
|
|
append = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
If set, zsh sessions will append their history list to the history
|
|
|
|
file, rather than replace it. Thus, multiple parallel zsh sessions
|
|
|
|
will all have the new entries from their history lists added to the
|
|
|
|
history file, in the order that they exit.
|
|
|
|
|
|
|
|
This file will still be periodically re-written to trim it when the
|
|
|
|
number of lines grows 20% beyond the value specified by
|
|
|
|
`programs.zsh.history.save`.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2017-08-23 12:51:54 +02:00
|
|
|
size = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 10000;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Number of history lines to keep.";
|
2017-08-23 12:51:54 +02:00
|
|
|
};
|
|
|
|
|
2018-01-12 17:23:58 +01:00
|
|
|
save = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
defaultText = 10000;
|
|
|
|
default = config.size;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Number of history lines to save.";
|
2018-01-12 17:23:58 +01:00
|
|
|
};
|
|
|
|
|
2017-08-23 12:51:54 +02:00
|
|
|
path = mkOption {
|
|
|
|
type = types.str;
|
2019-10-28 11:11:44 +01:00
|
|
|
default = if versionAtLeast stateVersion "20.03"
|
|
|
|
then "$HOME/.zsh_history"
|
|
|
|
else relToDotDir ".zsh_history";
|
2021-10-09 11:14:08 +02:00
|
|
|
defaultText = literalExpression ''
|
2021-05-05 23:19:12 +02:00
|
|
|
"$HOME/.zsh_history" if state version ≥ 20.03,
|
|
|
|
"$ZDOTDIR/.zsh_history" otherwise
|
|
|
|
'';
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression ''"''${config.xdg.dataHome}/zsh/zsh_history"'';
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "History file location";
|
2017-08-23 12:51:54 +02:00
|
|
|
};
|
|
|
|
|
2021-05-01 22:33:45 +02:00
|
|
|
ignorePatterns = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [];
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression ''[ "rm *" "pkill *" ]'';
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2021-05-01 22:33:45 +02:00
|
|
|
Do not enter command lines into the history list
|
|
|
|
if they match any one of the given shell patterns.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2017-08-23 12:51:54 +02:00
|
|
|
ignoreDups = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2017-08-23 12:51:54 +02:00
|
|
|
Do not enter command lines into the history list
|
|
|
|
if they are duplicates of the previous event.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-08-04 12:12:57 +02:00
|
|
|
ignoreAllDups = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
If a new command line being added to the history list
|
|
|
|
duplicates an older one, the older command is removed
|
|
|
|
from the list (even if it is not the previous event).
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-01-22 20:08:21 +01:00
|
|
|
ignoreSpace = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2020-01-22 20:08:21 +01:00
|
|
|
Do not enter command lines into the history list
|
|
|
|
if the first character is a space.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2018-06-06 22:32:46 +02:00
|
|
|
expireDuplicatesFirst = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Expire duplicates first.";
|
2018-06-06 22:32:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
extended = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Save timestamp into the history file.";
|
2018-06-06 22:32:46 +02:00
|
|
|
};
|
|
|
|
|
2017-08-23 12:51:54 +02:00
|
|
|
share = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Share command history between zsh sessions.";
|
2017-08-23 12:51:54 +02:00
|
|
|
};
|
|
|
|
};
|
2018-01-12 17:23:58 +01:00
|
|
|
});
|
2017-08-23 12:51:54 +02:00
|
|
|
|
2017-09-04 16:39:14 +02:00
|
|
|
pluginModule = types.submodule ({ config, ... }: {
|
|
|
|
options = {
|
|
|
|
src = mkOption {
|
|
|
|
type = types.path;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2017-09-04 16:39:14 +02:00
|
|
|
Path to the plugin folder.
|
|
|
|
|
2023-07-01 01:30:13 +02:00
|
|
|
Will be added to {env}`fpath` and {env}`PATH`.
|
2017-09-04 16:39:14 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
name = mkOption {
|
|
|
|
type = types.str;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2017-09-04 16:39:14 +02:00
|
|
|
The name of the plugin.
|
|
|
|
|
2023-07-01 01:30:13 +02:00
|
|
|
Don't forget to add {option}`file`
|
2017-09-04 16:39:14 +02:00
|
|
|
if the script name does not follow convention.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
file = mkOption {
|
|
|
|
type = types.str;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "The plugin script to source.";
|
2017-09-04 16:39:14 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config.file = mkDefault "${config.name}.plugin.zsh";
|
|
|
|
});
|
|
|
|
|
2017-09-07 23:57:13 +02:00
|
|
|
ohMyZshModule = types.submodule {
|
|
|
|
options = {
|
2023-07-02 01:45:18 +02:00
|
|
|
enable = mkEnableOption "oh-my-zsh";
|
2017-09-07 23:57:13 +02:00
|
|
|
|
2023-07-02 01:45:18 +02:00
|
|
|
package = mkPackageOption pkgs "oh-my-zsh" { };
|
2023-03-09 06:21:17 +01:00
|
|
|
|
2017-09-07 23:57:13 +02:00
|
|
|
plugins = mkOption {
|
|
|
|
default = [];
|
|
|
|
example = [ "git" "sudo" ];
|
|
|
|
type = types.listOf types.str;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2017-09-07 23:57:13 +02:00
|
|
|
List of oh-my-zsh plugins
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
custom = mkOption {
|
|
|
|
default = "";
|
|
|
|
type = types.str;
|
|
|
|
example = "$HOME/my_customizations";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2017-09-30 12:10:52 +02:00
|
|
|
Path to a custom oh-my-zsh package to override config of
|
2023-07-01 01:30:13 +02:00
|
|
|
oh-my-zsh. See <https://github.com/robbyrussell/oh-my-zsh/wiki/Customization>
|
2017-09-30 12:10:52 +02:00
|
|
|
for more information.
|
2017-09-07 23:57:13 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
theme = mkOption {
|
|
|
|
default = "";
|
|
|
|
example = "robbyrussell";
|
|
|
|
type = types.str;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2017-09-07 23:57:13 +02:00
|
|
|
Name of the theme to be used by oh-my-zsh.
|
|
|
|
'';
|
|
|
|
};
|
2020-03-25 15:40:42 +01:00
|
|
|
|
|
|
|
extraConfig = mkOption {
|
|
|
|
default = "";
|
|
|
|
example = ''
|
|
|
|
zstyle :omz:plugins:ssh-agent identities id_rsa id_rsa2 id_github
|
|
|
|
'';
|
|
|
|
type = types.lines;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2020-03-25 15:40:42 +01:00
|
|
|
Extra settings for plugins.
|
|
|
|
'';
|
|
|
|
};
|
2017-09-07 23:57:13 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-09-13 22:06:52 +02:00
|
|
|
historySubstringSearchModule = types.submodule {
|
|
|
|
options = {
|
2023-07-02 01:45:18 +02:00
|
|
|
enable = mkEnableOption "history substring search";
|
2022-09-13 22:06:52 +02:00
|
|
|
searchUpKey = mkOption {
|
2023-04-29 16:53:09 +02:00
|
|
|
type = with types; either (listOf str) str ;
|
|
|
|
default = [ "^[[A" ];
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2023-04-29 16:53:09 +02:00
|
|
|
The key codes to be used when searching up.
|
2023-10-10 19:09:38 +02:00
|
|
|
The default of `^[[A` may correspond to the UP key -- if not, try
|
|
|
|
`$terminfo[kcuu1]`.
|
2022-09-13 22:06:52 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
searchDownKey = mkOption {
|
2023-04-29 16:53:09 +02:00
|
|
|
type = with types; either (listOf str) str ;
|
|
|
|
default = [ "^[[B" ];
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2023-04-29 16:53:09 +02:00
|
|
|
The key codes to be used when searching down.
|
2023-10-10 19:09:38 +02:00
|
|
|
The default of `^[[B` may correspond to the DOWN key -- if not, try
|
|
|
|
`$terminfo[kcud1]`.
|
2022-09-13 22:06:52 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-06-28 11:12:58 +02:00
|
|
|
syntaxHighlightingModule = types.submodule {
|
|
|
|
options = {
|
2023-07-02 01:45:18 +02:00
|
|
|
enable = mkEnableOption "zsh syntax highlighting";
|
2023-06-28 11:12:58 +02:00
|
|
|
|
2023-07-02 01:45:18 +02:00
|
|
|
package = mkPackageOption pkgs "zsh-syntax-highlighting" { };
|
2023-06-28 11:12:58 +02:00
|
|
|
|
2023-11-19 19:37:32 +01:00
|
|
|
highlighters = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ ];
|
|
|
|
example = [ "brackets" ];
|
|
|
|
description = ''
|
|
|
|
Highlighters to enable
|
|
|
|
See the list of highlighters: <https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md>
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-02-08 15:17:24 +01:00
|
|
|
patterns = mkOption {
|
|
|
|
type = types.attrsOf types.str;
|
|
|
|
default = {};
|
|
|
|
example = { "rm -rf *" = "fg=white,bold,bg=red"; };
|
|
|
|
description = ''
|
|
|
|
Custom syntax highlighting for user-defined patterns.
|
|
|
|
Reference: <https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/pattern.md>
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-06-28 11:12:58 +02:00
|
|
|
styles = mkOption {
|
|
|
|
type = types.attrsOf types.str;
|
|
|
|
default = {};
|
2023-11-19 19:37:32 +01:00
|
|
|
example = { comment = "fg=black,bold"; };
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2023-06-28 11:12:58 +02:00
|
|
|
Custom styles for syntax highlighting.
|
2024-02-08 15:15:55 +01:00
|
|
|
See each highlighter style option: <https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/main.md>
|
2023-06-28 11:12:58 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-08-15 13:54:33 +02:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
2023-06-28 11:12:58 +02:00
|
|
|
imports = [
|
2023-11-26 01:09:47 +01:00
|
|
|
(mkRenamedOptionModule [ "programs" "zsh" "enableAutosuggestions" ] [ "programs" "zsh" "autosuggestion" "enable" ])
|
2023-06-28 11:12:58 +02:00
|
|
|
(mkRenamedOptionModule [ "programs" "zsh" "enableSyntaxHighlighting" ] [ "programs" "zsh" "syntaxHighlighting" "enable" ])
|
2024-01-03 11:05:13 +01:00
|
|
|
(mkRenamedOptionModule [ "programs" "zsh" "zproof" ] [ "programs" "zsh" "zprof" ])
|
2023-06-28 11:12:58 +02:00
|
|
|
];
|
|
|
|
|
2017-08-15 13:54:33 +02:00
|
|
|
options = {
|
|
|
|
programs.zsh = {
|
2023-07-02 01:45:18 +02:00
|
|
|
enable = mkEnableOption "Z shell (Zsh)";
|
2017-08-15 13:54:33 +02:00
|
|
|
|
2023-07-02 01:45:18 +02:00
|
|
|
package = mkPackageOption pkgs "zsh" { };
|
2023-05-11 01:54:34 +02:00
|
|
|
|
2019-05-10 21:38:36 +02:00
|
|
|
autocd = mkOption {
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-05-10 21:38:36 +02:00
|
|
|
Automatically enter into a directory if typed directly into shell.
|
|
|
|
'';
|
|
|
|
type = types.nullOr types.bool;
|
|
|
|
};
|
|
|
|
|
2020-08-14 22:36:23 +02:00
|
|
|
cdpath = mkOption {
|
|
|
|
default = [];
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2023-07-01 00:35:51 +02:00
|
|
|
List of paths to autocomplete calls to {command}`cd`.
|
2020-08-14 22:36:23 +02:00
|
|
|
'';
|
|
|
|
type = types.listOf types.str;
|
|
|
|
};
|
|
|
|
|
2017-09-12 20:01:02 +02:00
|
|
|
dotDir = mkOption {
|
|
|
|
default = null;
|
|
|
|
example = ".config/zsh";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2017-09-12 20:01:02 +02:00
|
|
|
Directory where the zsh configuration and more should be located,
|
|
|
|
relative to the users home directory. The default is the home
|
|
|
|
directory.
|
|
|
|
'';
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
};
|
|
|
|
|
2017-08-15 13:54:33 +02:00
|
|
|
shellAliases = mkOption {
|
|
|
|
default = {};
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression ''
|
2020-02-26 22:44:54 +01:00
|
|
|
{
|
|
|
|
ll = "ls -l";
|
|
|
|
".." = "cd ..";
|
|
|
|
}
|
|
|
|
'';
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2017-08-15 13:54:33 +02:00
|
|
|
An attribute set that maps aliases (the top level attribute names in
|
|
|
|
this option) to command strings or directly to build outputs.
|
|
|
|
'';
|
2019-03-31 13:22:27 +02:00
|
|
|
type = types.attrsOf types.str;
|
2017-08-15 13:54:33 +02:00
|
|
|
};
|
|
|
|
|
2020-07-20 19:54:30 +02:00
|
|
|
shellGlobalAliases = mkOption {
|
|
|
|
default = {};
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression ''
|
2020-07-20 19:54:30 +02:00
|
|
|
{
|
|
|
|
UUID = "$(uuidgen | tr -d \\n)";
|
|
|
|
G = "| grep";
|
|
|
|
}
|
|
|
|
'';
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2023-07-01 01:30:13 +02:00
|
|
|
Similar to [](#opt-programs.zsh.shellAliases),
|
2020-07-21 01:10:54 +02:00
|
|
|
but are substituted anywhere on a line.
|
2020-07-20 19:54:30 +02:00
|
|
|
'';
|
|
|
|
type = types.attrsOf types.str;
|
|
|
|
};
|
|
|
|
|
2020-10-27 12:46:26 +01:00
|
|
|
dirHashes = mkOption {
|
|
|
|
default = {};
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression ''
|
2020-10-27 12:46:26 +01:00
|
|
|
{
|
|
|
|
docs = "$HOME/Documents";
|
|
|
|
vids = "$HOME/Videos";
|
|
|
|
dl = "$HOME/Downloads";
|
|
|
|
}
|
|
|
|
'';
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2020-10-27 12:46:26 +01:00
|
|
|
An attribute set that adds to named directory hash table.
|
|
|
|
'';
|
|
|
|
type = types.attrsOf types.str;
|
|
|
|
};
|
|
|
|
|
2017-08-15 13:54:33 +02:00
|
|
|
enableCompletion = mkOption {
|
|
|
|
default = true;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2018-01-29 11:30:26 +01:00
|
|
|
Enable zsh completion. Don't forget to add
|
2023-07-01 01:30:13 +02:00
|
|
|
```nix
|
2018-01-29 11:30:26 +01:00
|
|
|
environment.pathsToLink = [ "/share/zsh" ];
|
2023-07-01 01:30:13 +02:00
|
|
|
```
|
2018-01-29 11:30:26 +01:00
|
|
|
to your system configuration to get completion for system packages (e.g. systemd).
|
|
|
|
'';
|
2017-08-15 13:54:33 +02:00
|
|
|
type = types.bool;
|
|
|
|
};
|
|
|
|
|
2021-06-09 17:15:10 +02:00
|
|
|
completionInit = mkOption {
|
|
|
|
default = "autoload -U compinit && compinit";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Initialization commands to run when completion is enabled.";
|
2021-06-09 17:15:10 +02:00
|
|
|
type = types.lines;
|
|
|
|
};
|
|
|
|
|
2024-01-03 11:05:13 +01:00
|
|
|
zprof.enable = mkOption {
|
2023-12-07 16:33:11 +01:00
|
|
|
default = false;
|
|
|
|
description = ''
|
2024-01-03 11:05:13 +01:00
|
|
|
Enable zprof in your zshrc.
|
2023-12-07 16:33:11 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-06-28 11:12:58 +02:00
|
|
|
syntaxHighlighting = mkOption {
|
|
|
|
type = syntaxHighlightingModule;
|
|
|
|
default = {};
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Options related to zsh-syntax-highlighting.";
|
2021-06-28 08:04:38 +02:00
|
|
|
};
|
|
|
|
|
2022-09-13 22:06:52 +02:00
|
|
|
historySubstringSearch = mkOption {
|
|
|
|
type = historySubstringSearchModule;
|
|
|
|
default = {};
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Options related to zsh-history-substring-search.";
|
2022-09-13 22:06:52 +02:00
|
|
|
};
|
|
|
|
|
2023-11-26 01:09:47 +01:00
|
|
|
autosuggestion = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Enable zsh autosuggestions";
|
|
|
|
};
|
|
|
|
|
|
|
|
highlight = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
example = "fg=#ff00ff,bg=cyan,bold,underline";
|
|
|
|
description = ''
|
|
|
|
Custom styles for autosuggestion highlighting. See
|
|
|
|
{manpage}`zshzle(1)` for syntax.
|
|
|
|
'';
|
|
|
|
};
|
2024-07-26 14:28:33 +02:00
|
|
|
|
|
|
|
strategy = mkOption {
|
|
|
|
type = types.listOf (types.enum [ "history" "completion" "match_prev_cmd" ]);
|
|
|
|
default = [ "history" ];
|
|
|
|
description = ''
|
|
|
|
`ZSH_AUTOSUGGEST_STRATEGY` is an array that specifies how suggestions should be generated.
|
|
|
|
The strategies in the array are tried successively until a suggestion is found.
|
|
|
|
There are currently three built-in strategies to choose from:
|
|
|
|
|
|
|
|
- `history`: Chooses the most recent match from history.
|
|
|
|
- `completion`: Chooses a suggestion based on what tab-completion would suggest. (requires `zpty` module)
|
|
|
|
- `match_prev_cmd`: Like `history`, but chooses the most recent match whose preceding history item matches
|
|
|
|
the most recently executed command. Note that this strategy won't work as expected with ZSH options that
|
|
|
|
don't preserve the history order such as `HIST_IGNORE_ALL_DUPS` or `HIST_EXPIRE_DUPS_FIRST`.
|
|
|
|
'';
|
|
|
|
};
|
2023-11-26 01:09:47 +01:00
|
|
|
};
|
|
|
|
|
2017-08-23 12:51:54 +02:00
|
|
|
history = mkOption {
|
|
|
|
type = historyModule;
|
|
|
|
default = {};
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Options related to commands history configuration.";
|
2017-08-15 13:54:33 +02:00
|
|
|
};
|
|
|
|
|
2018-12-16 15:23:08 +01:00
|
|
|
defaultKeymap = mkOption {
|
2018-12-23 11:53:01 +01:00
|
|
|
type = types.nullOr (types.enum (attrNames bindkeyCommands));
|
2018-12-16 15:23:08 +01:00
|
|
|
default = null;
|
|
|
|
example = "emacs";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "The default base keymap to use.";
|
2018-12-16 15:23:08 +01:00
|
|
|
};
|
|
|
|
|
2017-10-12 13:20:23 +02:00
|
|
|
sessionVariables = mkOption {
|
|
|
|
default = {};
|
2019-04-27 00:21:18 +02:00
|
|
|
type = types.attrs;
|
2018-01-25 14:13:44 +01:00
|
|
|
example = { MAILCHECK = 30; };
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Environment variables that will be set for zsh session.";
|
2017-10-12 13:20:23 +02:00
|
|
|
};
|
|
|
|
|
2019-07-23 21:40:41 +02:00
|
|
|
initExtraBeforeCompInit = mkOption {
|
|
|
|
default = "";
|
|
|
|
type = types.lines;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Extra commands that should be added to {file}`.zshrc` before compinit.";
|
2019-07-23 21:40:41 +02:00
|
|
|
};
|
|
|
|
|
2017-08-15 13:54:33 +02:00
|
|
|
initExtra = mkOption {
|
|
|
|
default = "";
|
|
|
|
type = types.lines;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Extra commands that should be added to {file}`.zshrc`.";
|
2017-09-04 16:39:14 +02:00
|
|
|
};
|
|
|
|
|
2020-08-17 03:50:29 +02:00
|
|
|
initExtraFirst = mkOption {
|
|
|
|
default = "";
|
|
|
|
type = types.lines;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Commands that should be added to top of {file}`.zshrc`.";
|
2020-08-17 03:50:29 +02:00
|
|
|
};
|
|
|
|
|
2019-07-23 21:58:06 +02:00
|
|
|
envExtra = mkOption {
|
|
|
|
default = "";
|
|
|
|
type = types.lines;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Extra commands that should be added to {file}`.zshenv`.";
|
2019-07-23 21:58:06 +02:00
|
|
|
};
|
|
|
|
|
2017-10-31 18:12:46 +01:00
|
|
|
profileExtra = mkOption {
|
|
|
|
default = "";
|
|
|
|
type = types.lines;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Extra commands that should be added to {file}`.zprofile`.";
|
2017-10-31 18:12:46 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
loginExtra = mkOption {
|
|
|
|
default = "";
|
|
|
|
type = types.lines;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Extra commands that should be added to {file}`.zlogin`.";
|
2017-10-31 18:12:46 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
logoutExtra = mkOption {
|
|
|
|
default = "";
|
|
|
|
type = types.lines;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Extra commands that should be added to {file}`.zlogout`.";
|
2017-10-31 18:12:46 +01:00
|
|
|
};
|
|
|
|
|
2017-09-04 16:39:14 +02:00
|
|
|
plugins = mkOption {
|
|
|
|
type = types.listOf pluginModule;
|
|
|
|
default = [];
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression ''
|
2017-09-04 16:39:14 +02:00
|
|
|
[
|
|
|
|
{
|
|
|
|
# will source zsh-autosuggestions.plugin.zsh
|
|
|
|
name = "zsh-autosuggestions";
|
|
|
|
src = pkgs.fetchFromGitHub {
|
|
|
|
owner = "zsh-users";
|
|
|
|
repo = "zsh-autosuggestions";
|
|
|
|
rev = "v0.4.0";
|
|
|
|
sha256 = "0z6i9wjjklb4lvr7zjhbphibsyx51psv50gm07mbb0kj9058j6kc";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "enhancd";
|
|
|
|
file = "init.sh";
|
|
|
|
src = pkgs.fetchFromGitHub {
|
|
|
|
owner = "b4b4r07";
|
|
|
|
repo = "enhancd";
|
|
|
|
rev = "v2.2.1";
|
|
|
|
sha256 = "0iqa9j09fwm6nj5rpip87x3hnvbbz9w9ajgm6wkrd5fls8fn8i5g";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
]
|
|
|
|
'';
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Plugins to source in {file}`.zshrc`.";
|
2017-08-15 13:54:33 +02:00
|
|
|
};
|
2017-09-07 23:57:13 +02:00
|
|
|
|
|
|
|
oh-my-zsh = mkOption {
|
|
|
|
type = ohMyZshModule;
|
|
|
|
default = {};
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Options to configure oh-my-zsh.";
|
2017-09-07 23:57:13 +02:00
|
|
|
};
|
2018-12-13 15:25:09 +01:00
|
|
|
|
|
|
|
localVariables = mkOption {
|
|
|
|
type = types.attrs;
|
|
|
|
default = {};
|
|
|
|
example = { POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=["dir" "vcs"]; };
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2023-07-01 01:30:13 +02:00
|
|
|
Extra local variables defined at the top of {file}`.zshrc`.
|
2018-12-13 15:25:09 +01:00
|
|
|
'';
|
|
|
|
};
|
2017-08-15 13:54:33 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-09-18 00:26:42 +02:00
|
|
|
config = mkIf cfg.enable (mkMerge [
|
2019-07-23 21:58:06 +02:00
|
|
|
(mkIf (cfg.envExtra != "") {
|
|
|
|
home.file."${relToDotDir ".zshenv"}".text = cfg.envExtra;
|
|
|
|
})
|
|
|
|
|
2018-01-25 14:13:44 +01:00
|
|
|
(mkIf (cfg.profileExtra != "") {
|
|
|
|
home.file."${relToDotDir ".zprofile"}".text = cfg.profileExtra;
|
|
|
|
})
|
|
|
|
|
|
|
|
(mkIf (cfg.loginExtra != "") {
|
|
|
|
home.file."${relToDotDir ".zlogin"}".text = cfg.loginExtra;
|
|
|
|
})
|
|
|
|
|
|
|
|
(mkIf (cfg.logoutExtra != "") {
|
|
|
|
home.file."${relToDotDir ".zlogout"}".text = cfg.logoutExtra;
|
|
|
|
})
|
|
|
|
|
|
|
|
(mkIf cfg.oh-my-zsh.enable {
|
|
|
|
home.file."${relToDotDir ".zshenv"}".text = ''
|
2023-03-09 06:21:17 +01:00
|
|
|
ZSH="${cfg.oh-my-zsh.package}/share/oh-my-zsh";
|
2019-08-08 15:24:23 +02:00
|
|
|
ZSH_CACHE_DIR="${config.xdg.cacheHome}/oh-my-zsh";
|
2018-01-25 14:13:44 +01:00
|
|
|
'';
|
|
|
|
})
|
|
|
|
|
|
|
|
(mkIf (cfg.dotDir != null) {
|
|
|
|
home.file."${relToDotDir ".zshenv"}".text = ''
|
2023-11-01 00:35:15 +01:00
|
|
|
export ZDOTDIR=${zdotdir}
|
2018-01-25 14:13:44 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
# When dotDir is set, only use ~/.zshenv to source ZDOTDIR/.zshenv,
|
|
|
|
# This is so that if ZDOTDIR happens to be
|
|
|
|
# already set correctly (by e.g. spawning a zsh inside a zsh), all env
|
|
|
|
# vars still get exported
|
|
|
|
home.file.".zshenv".text = ''
|
|
|
|
source ${zdotdir}/.zshenv
|
|
|
|
'';
|
|
|
|
})
|
|
|
|
|
zsh: move sessionVariables from .zshrc to .zshenv (#2708)
This patch moves both home.sessionVariables and
programs.zsh.sessionVariables from .zshrc to .zshenv. Additionally,
these two kinds of session variables will not be sourced more than
once to allow user-customized ones to take effect.
Before, session variables are in .zshrc, which causes non-interactive
shells to not be able to get those variables. For example, running a
command through SSH is in a non-interactive and non-login shell, which
suffers from this. With this patch, all kinds of shells can get
session variables.
The reason why these session variables are not moved to .zprofile is
that programs started by systemd user instances are not able to get
variables defined in that file. For example, GNOME
Terminal (gnome-terminal-server.service) is one of these programs and
doesn't get variables defined in .zprofile. As a result, the shells it
starts, which are interactive and non-login, do not get those
variables.
Fixes #2445
Related NixOS/nixpkgs#33219
Related NixOS/nixpkgs#45784
This file is not formatted before and is excluded by ./format, so I don't format it.
2022-02-17 10:20:56 +01:00
|
|
|
{
|
|
|
|
home.file."${relToDotDir ".zshenv"}".text = ''
|
|
|
|
# Environment variables
|
|
|
|
. "${config.home.profileDirectory}/etc/profile.d/hm-session-vars.sh"
|
|
|
|
|
|
|
|
# Only source this once
|
|
|
|
if [[ -z "$__HM_ZSH_SESS_VARS_SOURCED" ]]; then
|
|
|
|
export __HM_ZSH_SESS_VARS_SOURCED=1
|
|
|
|
${envVarsStr}
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
|
2017-09-18 00:26:42 +02:00
|
|
|
{
|
2023-05-11 01:54:34 +02:00
|
|
|
home.packages = [ cfg.package ]
|
|
|
|
++ optional cfg.enableCompletion pkgs.nix-zsh-completions
|
2023-03-09 06:21:17 +01:00
|
|
|
++ optional cfg.oh-my-zsh.enable cfg.oh-my-zsh.package;
|
2017-08-15 13:54:33 +02:00
|
|
|
|
2022-11-18 17:27:43 +01:00
|
|
|
home.file."${relToDotDir ".zshrc"}".text = concatStringsSep "\n" ([
|
2024-01-03 11:05:13 +01:00
|
|
|
# zprof must be loaded before everything else, since it
|
2023-12-07 16:33:11 +01:00
|
|
|
# benchmarks the shell initialization.
|
2024-01-03 11:05:13 +01:00
|
|
|
(optionalString cfg.zprof.enable ''
|
2023-12-07 16:33:11 +01:00
|
|
|
zmodload zsh/zprof
|
|
|
|
'')
|
|
|
|
|
2022-11-18 17:27:43 +01:00
|
|
|
cfg.initExtraFirst
|
|
|
|
"typeset -U path cdpath fpath manpath"
|
2018-01-29 11:30:26 +01:00
|
|
|
|
2022-11-18 17:27:43 +01:00
|
|
|
(optionalString (cfg.cdpath != []) ''
|
2020-08-14 22:36:23 +02:00
|
|
|
cdpath+=(${concatStringsSep " " cfg.cdpath})
|
2022-11-18 17:27:43 +01:00
|
|
|
'')
|
2020-08-14 22:36:23 +02:00
|
|
|
|
2022-11-18 17:27:43 +01:00
|
|
|
''
|
2018-01-29 11:30:26 +01:00
|
|
|
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
|
2017-09-05 14:21:57 +02:00
|
|
|
|
2023-05-11 01:54:34 +02:00
|
|
|
HELPDIR="${cfg.package}/share/zsh/$ZSH_VERSION/help"
|
2022-11-18 17:27:43 +01:00
|
|
|
''
|
2017-08-23 13:06:19 +02:00
|
|
|
|
2022-11-18 17:27:43 +01:00
|
|
|
(optionalString (cfg.defaultKeymap != null) ''
|
2018-12-23 11:53:01 +01:00
|
|
|
# Use ${cfg.defaultKeymap} keymap as the default.
|
|
|
|
${getAttr cfg.defaultKeymap bindkeyCommands}
|
2022-11-18 17:27:43 +01:00
|
|
|
'')
|
|
|
|
localVarsStr
|
2018-12-16 15:23:08 +01:00
|
|
|
|
2022-11-18 17:27:43 +01:00
|
|
|
cfg.initExtraBeforeCompInit
|
2018-12-13 15:25:09 +01:00
|
|
|
|
2022-11-18 17:27:43 +01:00
|
|
|
(concatStrings (map (plugin: ''
|
2017-09-12 20:01:02 +02:00
|
|
|
path+="$HOME/${pluginsDir}/${plugin.name}"
|
|
|
|
fpath+="$HOME/${pluginsDir}/${plugin.name}"
|
2022-11-18 17:27:43 +01:00
|
|
|
'') cfg.plugins))
|
2017-09-04 16:39:14 +02:00
|
|
|
|
2022-11-18 17:27:43 +01:00
|
|
|
''
|
2020-10-12 02:27:44 +02:00
|
|
|
# Oh-My-Zsh/Prezto calls compinit during initialization,
|
2021-02-09 03:11:56 +01:00
|
|
|
# calling it twice causes slight start up slowdown
|
2019-08-08 14:57:53 +02:00
|
|
|
# as all $fpath entries will be traversed again.
|
2020-10-12 02:27:44 +02:00
|
|
|
${optionalString (cfg.enableCompletion && !cfg.oh-my-zsh.enable && !cfg.prezto.enable)
|
2021-06-09 17:15:10 +02:00
|
|
|
cfg.completionInit
|
2023-11-26 01:09:47 +01:00
|
|
|
}''
|
2019-08-08 14:57:53 +02:00
|
|
|
|
2023-11-26 01:09:47 +01:00
|
|
|
(optionalString cfg.autosuggestion.enable ''
|
|
|
|
source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh
|
2024-07-26 14:28:33 +02:00
|
|
|
ZSH_AUTOSUGGEST_STRATEGY=(${concatStringsSep " " cfg.autosuggestion.strategy})
|
2023-11-26 01:09:47 +01:00
|
|
|
'')
|
|
|
|
(optionalString (cfg.autosuggestion.enable && cfg.autosuggestion.highlight != null) ''
|
2024-04-24 22:59:02 +02:00
|
|
|
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="${cfg.autosuggestion.highlight}"
|
2023-11-26 01:09:47 +01:00
|
|
|
'')
|
2017-08-15 13:54:33 +02:00
|
|
|
|
2023-11-26 01:09:47 +01:00
|
|
|
(optionalString cfg.oh-my-zsh.enable ''
|
2020-03-25 15:40:42 +01:00
|
|
|
# oh-my-zsh extra settings for plugins
|
|
|
|
${cfg.oh-my-zsh.extraConfig}
|
2017-09-07 23:57:13 +02:00
|
|
|
# oh-my-zsh configuration generated by NixOS
|
|
|
|
${optionalString (cfg.oh-my-zsh.plugins != [])
|
|
|
|
"plugins=(${concatStringsSep " " cfg.oh-my-zsh.plugins})"
|
|
|
|
}
|
|
|
|
${optionalString (cfg.oh-my-zsh.custom != "")
|
|
|
|
"ZSH_CUSTOM=\"${cfg.oh-my-zsh.custom}\""
|
|
|
|
}
|
|
|
|
${optionalString (cfg.oh-my-zsh.theme != "")
|
|
|
|
"ZSH_THEME=\"${cfg.oh-my-zsh.theme}\""
|
|
|
|
}
|
|
|
|
source $ZSH/oh-my-zsh.sh
|
2023-11-26 01:09:47 +01:00
|
|
|
'')
|
2017-09-07 23:57:13 +02:00
|
|
|
|
2023-11-26 01:09:47 +01:00
|
|
|
''
|
2020-10-12 02:27:44 +02:00
|
|
|
${optionalString cfg.prezto.enable
|
2021-02-09 03:11:56 +01:00
|
|
|
(builtins.readFile "${pkgs.zsh-prezto}/share/zsh-prezto/runcoms/zshrc")}
|
2020-10-12 02:27:44 +02:00
|
|
|
|
2017-09-04 16:39:14 +02:00
|
|
|
${concatStrings (map (plugin: ''
|
2021-06-09 17:15:10 +02:00
|
|
|
if [[ -f "$HOME/${pluginsDir}/${plugin.name}/${plugin.file}" ]]; then
|
2018-04-16 22:12:53 +02:00
|
|
|
source "$HOME/${pluginsDir}/${plugin.name}/${plugin.file}"
|
|
|
|
fi
|
2017-09-04 16:39:14 +02:00
|
|
|
'') cfg.plugins)}
|
|
|
|
|
2018-01-12 17:23:58 +01:00
|
|
|
# History options should be set in .zshrc and after oh-my-zsh sourcing.
|
2020-10-19 21:20:37 +02:00
|
|
|
# See https://github.com/nix-community/home-manager/issues/177.
|
2018-01-12 11:24:08 +01:00
|
|
|
HISTSIZE="${toString cfg.history.size}"
|
2018-01-12 17:23:58 +01:00
|
|
|
SAVEHIST="${toString cfg.history.save}"
|
2021-05-01 22:33:45 +02:00
|
|
|
${optionalString (cfg.history.ignorePatterns != []) "HISTORY_IGNORE=${lib.escapeShellArg "(${lib.concatStringsSep "|" cfg.history.ignorePatterns})"}"}
|
2019-10-28 11:11:44 +01:00
|
|
|
${if versionAtLeast config.home.stateVersion "20.03"
|
|
|
|
then ''HISTFILE="${cfg.history.path}"''
|
|
|
|
else ''HISTFILE="$HOME/${cfg.history.path}"''}
|
|
|
|
mkdir -p "$(dirname "$HISTFILE")"
|
2018-01-12 17:23:58 +01:00
|
|
|
|
|
|
|
setopt HIST_FCNTL_LOCK
|
2024-08-23 13:29:12 +02:00
|
|
|
${if cfg.history.append then "setopt" else "unsetopt"} APPEND_HISTORY
|
2018-01-12 17:23:58 +01:00
|
|
|
${if cfg.history.ignoreDups then "setopt" else "unsetopt"} HIST_IGNORE_DUPS
|
2023-08-04 12:12:57 +02:00
|
|
|
${if cfg.history.ignoreAllDups then "setopt" else "unsetopt"} HIST_IGNORE_ALL_DUPS
|
2020-01-22 20:08:21 +01:00
|
|
|
${if cfg.history.ignoreSpace then "setopt" else "unsetopt"} HIST_IGNORE_SPACE
|
2018-06-06 22:32:46 +02:00
|
|
|
${if cfg.history.expireDuplicatesFirst then "setopt" else "unsetopt"} HIST_EXPIRE_DUPS_FIRST
|
2018-01-12 17:23:58 +01:00
|
|
|
${if cfg.history.share then "setopt" else "unsetopt"} SHARE_HISTORY
|
2018-06-06 22:32:46 +02:00
|
|
|
${if cfg.history.extended then "setopt" else "unsetopt"} EXTENDED_HISTORY
|
2019-05-10 21:38:36 +02:00
|
|
|
${if cfg.autocd != null then "${if cfg.autocd then "setopt" else "unsetopt"} autocd" else ""}
|
2018-01-12 11:24:08 +01:00
|
|
|
|
2017-08-15 13:54:33 +02:00
|
|
|
${cfg.initExtra}
|
2017-09-07 22:21:00 +02:00
|
|
|
|
2018-01-25 14:13:44 +01:00
|
|
|
# Aliases
|
2017-09-07 22:21:00 +02:00
|
|
|
${aliasesStr}
|
2022-11-18 17:27:43 +01:00
|
|
|
''
|
2024-02-22 17:55:26 +01:00
|
|
|
]
|
|
|
|
++ (mapAttrsToList (k: v: "alias -g -- ${lib.escapeShellArg k}=${lib.escapeShellArg v}") cfg.shellGlobalAliases)
|
2022-11-18 17:27:43 +01:00
|
|
|
++ [ (''
|
2020-10-27 12:46:26 +01:00
|
|
|
# Named Directory Hashes
|
|
|
|
${dirHashesStr}
|
2022-11-18 17:27:43 +01:00
|
|
|
'')
|
2022-07-08 02:57:27 +02:00
|
|
|
|
2023-06-28 11:12:58 +02:00
|
|
|
(optionalString cfg.syntaxHighlighting.enable
|
2022-09-13 22:06:52 +02:00
|
|
|
# Load zsh-syntax-highlighting after all custom widgets have been created
|
2022-07-08 02:57:27 +02:00
|
|
|
# https://github.com/zsh-users/zsh-syntax-highlighting#faq
|
2023-06-28 11:12:58 +02:00
|
|
|
''
|
|
|
|
source ${cfg.syntaxHighlighting.package}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
2023-11-19 19:37:32 +01:00
|
|
|
ZSH_HIGHLIGHT_HIGHLIGHTERS+=(${lib.concatStringsSep " " (map lib.escapeShellArg cfg.syntaxHighlighting.highlighters)})
|
2023-06-28 11:12:58 +02:00
|
|
|
${lib.concatStringsSep "\n" (
|
|
|
|
lib.mapAttrsToList
|
2023-07-15 11:49:12 +02:00
|
|
|
(name: value: "ZSH_HIGHLIGHT_STYLES+=(${lib.escapeShellArg name} ${lib.escapeShellArg value})")
|
2023-06-28 11:12:58 +02:00
|
|
|
cfg.syntaxHighlighting.styles
|
|
|
|
)}
|
2024-02-08 15:17:24 +01:00
|
|
|
${lib.concatStringsSep "\n" (
|
|
|
|
lib.mapAttrsToList
|
|
|
|
(name: value: "ZSH_HIGHLIGHT_PATTERNS+=(${lib.escapeShellArg name} ${lib.escapeShellArg value})")
|
|
|
|
cfg.syntaxHighlighting.patterns
|
|
|
|
)}
|
2023-06-28 11:12:58 +02:00
|
|
|
'')
|
2022-11-18 17:27:43 +01:00
|
|
|
|
|
|
|
(optionalString (cfg.historySubstringSearch.enable or false)
|
2022-09-13 22:06:52 +02:00
|
|
|
# Load zsh-history-substring-search after zsh-syntax-highlighting
|
|
|
|
# https://github.com/zsh-users/zsh-history-substring-search#usage
|
|
|
|
''
|
|
|
|
source ${pkgs.zsh-history-substring-search}/share/zsh-history-substring-search/zsh-history-substring-search.zsh
|
2023-04-29 16:53:09 +02:00
|
|
|
${lib.concatMapStringsSep "\n"
|
2023-10-10 19:09:38 +02:00
|
|
|
(upKey: "bindkey \"${upKey}\" history-substring-search-up")
|
2023-04-29 16:53:09 +02:00
|
|
|
(lib.toList cfg.historySubstringSearch.searchUpKey)
|
|
|
|
}
|
|
|
|
${lib.concatMapStringsSep "\n"
|
2023-10-10 19:09:38 +02:00
|
|
|
(downKey: "bindkey \"${downKey}\" history-substring-search-down")
|
2023-04-29 16:53:09 +02:00
|
|
|
(lib.toList cfg.historySubstringSearch.searchDownKey)
|
|
|
|
}
|
2022-11-18 17:27:43 +01:00
|
|
|
'')
|
2023-12-07 16:33:11 +01:00
|
|
|
|
2024-01-03 11:05:13 +01:00
|
|
|
(optionalString cfg.zprof.enable
|
2023-12-07 16:33:11 +01:00
|
|
|
''
|
|
|
|
zprof
|
|
|
|
'')
|
2022-11-18 17:27:43 +01:00
|
|
|
]);
|
2017-09-18 00:26:42 +02:00
|
|
|
}
|
2017-10-13 16:34:02 +02:00
|
|
|
|
2017-09-07 23:57:13 +02:00
|
|
|
(mkIf cfg.oh-my-zsh.enable {
|
2019-08-08 15:24:23 +02:00
|
|
|
# Make sure we create a cache directory since some plugins expect it to exist
|
2020-10-19 21:20:37 +02:00
|
|
|
# See: https://github.com/nix-community/home-manager/issues/761
|
2019-08-08 15:24:23 +02:00
|
|
|
home.file."${config.xdg.cacheHome}/oh-my-zsh/.keep".text = "";
|
2017-09-07 23:57:13 +02:00
|
|
|
})
|
2017-10-13 16:34:02 +02:00
|
|
|
|
2017-09-04 16:39:14 +02:00
|
|
|
(mkIf (cfg.plugins != []) {
|
|
|
|
# Many plugins require compinit to be called
|
|
|
|
# but allow the user to opt out.
|
|
|
|
programs.zsh.enableCompletion = mkDefault true;
|
|
|
|
|
2020-01-11 19:49:15 +01:00
|
|
|
home.file =
|
|
|
|
foldl' (a: b: a // b) {}
|
|
|
|
(map (plugin: { "${pluginsDir}/${plugin.name}".source = plugin.src; })
|
|
|
|
cfg.plugins);
|
2017-09-04 16:39:14 +02:00
|
|
|
})
|
2017-09-18 00:26:42 +02:00
|
|
|
]);
|
2017-08-15 13:54:33 +02:00
|
|
|
}
|