mirror of
https://github.com/nix-community/home-manager.git
synced 2024-12-14 11:57:55 +00:00
zsh: add history.ignorePatterns option (#1933)
The corresponding variable is `HISTORY_IGNORE` described in zshparam(1).
This commit is contained in:
parent
19fc0917c0
commit
5709b5f953
3 changed files with 33 additions and 0 deletions
|
@ -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}"''}
|
||||
|
|
|
@ -4,5 +4,6 @@
|
|||
zsh-history-path-new-custom = ./history-path-new-custom.nix;
|
||||
zsh-history-path-old-default = ./history-path-old-default.nix;
|
||||
zsh-history-path-old-custom = ./history-path-old-custom.nix;
|
||||
zsh-history-ignore-pattern = ./history-ignore-pattern.nix;
|
||||
zsh-prezto = ./prezto.nix;
|
||||
}
|
||||
|
|
21
tests/modules/programs/zsh/history-ignore-pattern.nix
Normal file
21
tests/modules/programs/zsh/history-ignore-pattern.nix
Normal file
|
@ -0,0 +1,21 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
imports = [
|
||||
({ ... }: { config.programs.zsh.history.ignorePatterns = [ "echo *" ]; })
|
||||
({ ... }: { config.programs.zsh.history.ignorePatterns = [ "rm *" ]; })
|
||||
];
|
||||
|
||||
config = {
|
||||
programs.zsh.enable = true;
|
||||
|
||||
nixpkgs.overlays =
|
||||
[ (self: super: { zsh = pkgs.writeScriptBin "dummy-zsh" ""; }) ];
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContains home-files/.zshrc "HISTORY_IGNORE='(echo *|rm *)'"
|
||||
'';
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue