zsh: add history.ignorePatterns option (#1933)

The corresponding variable is `HISTORY_IGNORE` described in zshparam(1).
This commit is contained in:
oxalica 2021-05-02 04:33:45 +08:00 committed by GitHub
parent 19fc0917c0
commit 5709b5f953
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 0 deletions

View file

@ -60,6 +60,16 @@ let
description = "History file location";
};
ignorePatterns = mkOption {
type = types.listOf types.str;
default = [];
example = literalExample ''[ "rm *" "pkill *" ]'';
description = ''
Do not enter command lines into the history list
if they match any one of the given shell patterns.
'';
};
ignoreDups = mkOption {
type = types.bool;
default = true;
@ -495,6 +505,7 @@ in
# See https://github.com/nix-community/home-manager/issues/177.
HISTSIZE="${toString cfg.history.size}"
SAVEHIST="${toString cfg.history.save}"
${optionalString (cfg.history.ignorePatterns != []) "HISTORY_IGNORE=${lib.escapeShellArg "(${lib.concatStringsSep "|" cfg.history.ignorePatterns})"}"}
${if versionAtLeast config.home.stateVersion "20.03"
then ''HISTFILE="${cfg.history.path}"''
else ''HISTFILE="$HOME/${cfg.history.path}"''}