1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2025-01-11 19:49:49 +01:00

zsh: add history.save option

This commit is contained in:
Nikita Uvarov 2018-01-12 17:23:58 +01:00
parent dbcb3dd1ae
commit a93445f3fe
No known key found for this signature in database
GPG key ID: F7A5FB3A7C10EF96

View file

@ -19,7 +19,7 @@ let
zdotdir = "$HOME/" + cfg.dotDir; zdotdir = "$HOME/" + cfg.dotDir;
historyModule = types.submodule { historyModule = types.submodule ({ config, ... }: {
options = { options = {
size = mkOption { size = mkOption {
type = types.int; type = types.int;
@ -27,6 +27,13 @@ let
description = "Number of history lines to keep."; 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 { path = mkOption {
type = types.str; type = types.str;
default = relToDotDir ".zsh_history"; default = relToDotDir ".zsh_history";
@ -49,7 +56,7 @@ let
description = "Share command history between zsh sessions."; description = "Share command history between zsh sessions.";
}; };
}; };
}; });
pluginModule = types.submodule ({ config, ... }: { pluginModule = types.submodule ({ config, ... }: {
options = { options = {
@ -247,10 +254,6 @@ in
''; '';
home.file."${relToDotDir ".zshrc"}".text = '' 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/site-functions"
fpath+="$HOME/.nix-profile/share/zsh/$ZSH_VERSION/functions" fpath+="$HOME/.nix-profile/share/zsh/$ZSH_VERSION/functions"
@ -284,10 +287,15 @@ in
source "$HOME/${pluginsDir}/${plugin.name}/${plugin.file}" source "$HOME/${pluginsDir}/${plugin.name}/${plugin.file}"
'') cfg.plugins)} '') cfg.plugins)}
# HISTSIZE, HISTFILE have to be set in .zshrc and after oh-my-zsh sourcing # History options should be set in .zshrc and after oh-my-zsh sourcing.
# see https://github.com/rycee/home-manager/issues/177 # See https://github.com/rycee/home-manager/issues/177.
HISTSIZE="${toString cfg.history.size}" HISTSIZE="${toString cfg.history.size}"
HISTFILE="$HOME/${cfg.history.path}" 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} ${cfg.initExtra}