Skip to content

Commit 843bba3

Browse files
committed
Keep short commands and cd/ls out of history file
1 parent 5bb53a5 commit 843bba3

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/dot_config/zsh/zshrc.d/history.zsh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ setopt interactive_comments
1414
setopt share_history # noka: ZC1928
1515

1616
# http://mollifier.hatenablog.com/entry/20090728/p1
17-
_history_min_length() {
17+
# Return 2 keeps the line in the session history (reusable with ^p) but out of HISTFILE.
18+
_history_no_save() {
1819
local line=${1%%$'\n'}
19-
((${#line} >= 4))
20+
((${#line} >= 4)) || return 2
21+
[[ $line != (cd|ls)(|' '*) ]] || return 2
2022
}
2123
autoload -Uz add-zsh-hook
22-
add-zsh-hook zshaddhistory _history_min_length
24+
add-zsh-hook zshaddhistory _history_no_save

0 commit comments

Comments
 (0)