1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-09-28 17:27:28 +02:00

zsh: add history submodule

This commit is contained in:
Nikita Uvarov 2017-08-23 12:51:54 +02:00 committed by Robert Helgesson
parent fed112e497
commit bd914d49f1
No known key found for this signature in database
GPG key ID: C3DB11069E65DC86

View file

@ -6,6 +6,37 @@ let
cfg = config.programs.zsh; cfg = config.programs.zsh;
historyModule = types.submodule {
options = {
size = mkOption {
type = types.int;
default = 10000;
description = "Number of history lines to keep.";
};
path = mkOption {
type = types.str;
default = "$HOME/.zsh_history";
description = "History file location";
};
ignoreDups = mkOption {
type = types.bool;
default = true;
description = ''
Do not enter command lines into the history list
if they are duplicates of the previous event.
'';
};
share = mkOption {
type = types.bool;
default = true;
description = "Share command history between zsh sessions.";
};
};
};
in in
{ {
@ -13,12 +44,6 @@ in
programs.zsh = { programs.zsh = {
enable = mkEnableOption "Z shell (Zsh)"; enable = mkEnableOption "Z shell (Zsh)";
historySize = mkOption {
type = types.int;
default = 10000;
description = "Number of history lines to keep.";
};
shellAliases = mkOption { shellAliases = mkOption {
default = {}; default = {};
example = { ll = "ls -l"; ".." = "cd .."; }; example = { ll = "ls -l"; ".." = "cd .."; };
@ -31,17 +56,19 @@ in
enableCompletion = mkOption { enableCompletion = mkOption {
default = true; default = true;
description = '' description = "Enable zsh completion.";
Enable zsh completion.
'';
type = types.bool; type = types.bool;
}; };
enableAutosuggestions = mkOption { enableAutosuggestions = mkOption {
default = false; default = false;
description = '' description = "Enable zsh autosuggestions";
Enable zsh autosuggestions };
'';
history = mkOption {
type = historyModule;
default = {};
description = "Options related to commands history configuration.";
}; };
initExtra = mkOption { initExtra = mkOption {
@ -59,11 +86,6 @@ in
); );
export = n: v: "export ${n}=\"${toString v}\""; export = n: v: "export ${n}=\"${toString v}\"";
exportIfNonNull = n: v: optionalString (v != null) (export n v);
exportIfNonEmpty = n: v: optionalString (v != "") (export n v);
histControlStr = concatStringsSep ":" cfg.historyControl;
histIgnoreStr = concatStringsSep ":" cfg.historyIgnore;
envVarsStr = concatStringsSep "\n" ( envVarsStr = concatStringsSep "\n" (
mapAttrsToList export config.home.sessionVariables mapAttrsToList export config.home.sessionVariables
@ -78,7 +100,12 @@ in
''; '';
home.file.".zshrc".text = '' home.file.".zshrc".text = ''
${export "HISTSIZE" cfg.historySize} ${export "HISTSIZE" cfg.history.size}
${export "HISTFILE" cfg.history.path}
setopt HIST_FCNTL_LOCK
${if cfg.history.ignoreDups then "setopt" else "unsetopt"} HIST_IGNORE_DUPS
${if cfg.history.share then "setopt" else "unsetopt"} SHARE_HISTORY
${if cfg.enableCompletion then "autoload -U compinit && compinit" else ""} ${if cfg.enableCompletion then "autoload -U compinit && compinit" else ""}
${optionalString (cfg.enableAutosuggestions) ${optionalString (cfg.enableAutosuggestions)