Skip to content

Commit

Permalink
Add history ignoring commands
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed Aug 24, 2023
1 parent 780d8bf commit e3ad49f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion home-manager/bash.nix
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
historyFile = "${config.xdg.stateHome}/bash/history";
historyFileSize = 4200000;
historyControl = [ "erasedups" "ignoredups" "ignorespace" ];
historyIgnore = [ "ls" "cd" "z" ];
# NOTE: I didn't check it should have different globs as zsh or not, at least the sepelator is not same.
historyIgnore = [ "cd" "pushd" "popd" "z" "ls" "ll" "la" "rm" "rmdir" "git show" "exit" ];

# Extracting because embedded here requires complex escape with nix multiline.
initExtra = ''
Expand Down
6 changes: 6 additions & 0 deletions home-manager/zsh.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
ignoreAllDups = true;
ignoreSpace = true;

# https://askubuntu.com/questions/999923/syntax-in-history-ignore
# https://github.com/zsh-users/zsh/blob/aa8e4a02904b3a1c4b3064eb7502d887f7de958b/Src/hist.c#L3006-L3015
ignorePatterns = [ "cd *" "pushd *" "popd *" "z *" "ls *" "ll *" "la *" "rm *" "rmdir *" "git show *" "exit" ];

# Hist memory size should be grater than saving file size if enabled
expireDuplicatesFirst = true;

Expand Down Expand Up @@ -134,6 +138,8 @@
source "${../dependencies/dprint/completions.zsh}"
# https://superuser.com/a/902508/120469
# https://github.com/zsh-users/zsh-autosuggestions/issues/259
zshaddhistory() { whence ''${''${(z)1}[1]} >| /dev/null || return 1 }
'';

Expand Down

0 comments on commit e3ad49f

Please sign in to comment.