From a93445f3fe5c3a2b0c4bb228519a7d3f03132d2a Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Fri, 12 Jan 2018 17:23:58 +0100 Subject: [PATCH] zsh: add history.save option --- modules/programs/zsh.nix | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index 954ecb6bc..9dcbece3f 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -19,7 +19,7 @@ let zdotdir = "$HOME/" + cfg.dotDir; - historyModule = types.submodule { + historyModule = types.submodule ({ config, ... }: { options = { size = mkOption { type = types.int; @@ -27,6 +27,13 @@ let description = "Number of history lines to keep."; }; + save = mkOption { + type = types.int; + defaultText = 10000; + default = config.size; + description = "Number of history lines to save."; + }; + path = mkOption { type = types.str; default = relToDotDir ".zsh_history"; @@ -49,7 +56,7 @@ let description = "Share command history between zsh sessions."; }; }; - }; + }); pluginModule = types.submodule ({ config, ... }: { options = { @@ -247,10 +254,6 @@ in ''; home.file."${relToDotDir ".zshrc"}".text = '' - 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 - fpath+="$HOME/.nix-profile/share/zsh/site-functions" fpath+="$HOME/.nix-profile/share/zsh/$ZSH_VERSION/functions" @@ -284,10 +287,15 @@ in source "$HOME/${pluginsDir}/${plugin.name}/${plugin.file}" '') cfg.plugins)} - # HISTSIZE, HISTFILE have to be set in .zshrc and after oh-my-zsh sourcing - # see https://github.com/rycee/home-manager/issues/177 + # History options should be set in .zshrc and after oh-my-zsh sourcing. + # See https://github.com/rycee/home-manager/issues/177. HISTSIZE="${toString cfg.history.size}" HISTFILE="$HOME/${cfg.history.path}" + SAVEHIST="${toString cfg.history.save}" + + 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 ${cfg.initExtra}