今天我在Mac上从bash切换到zsh(+ oh-my-zsh)。在bash中,我保留了.bash_eternal_history
个超过30,000个条目。我将其迁移到.zsh_history
文件和格式。
现在我设置这些变量以保持zsh中的永恒历史(取自[1]):
HISTFILE="$HOME/.zsh_history"
HISTSIZE=10000000
SAVEHIST=10000000
setopt BANG_HIST # Treat the '!' character specially during expansion.
setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format.
setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits.
setopt SHARE_HISTORY # Share history between all sessions.
setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history.
setopt HIST_IGNORE_DUPS # Don't record an entry that was just recorded again.
setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate.
setopt HIST_FIND_NO_DUPS # Do not display a line previously found.
setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space.
setopt HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file.
setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry.
setopt HIST_VERIFY # Don't execute immediately upon history expansion.
setopt HIST_BEEP # Beep when accessing nonexistent history.
[1] https://unix.stackexchange.com/a/273863
但SAVEHIST中的数字被忽略了。无论我设置多高,当我在我的shell中输入echo $SAVEHIST
时,我会收到10,000
,而我的.zsh_history
文件超过30,000个条目的上限为10,000
我错过了什么?
答案 0 :(得分:0)
我已将此部分从.zshrc
移至~/opts/args.sh
,并在.zshrc
中添加了行source ~/opts/args.sh
。这解决了它
答案 1 :(得分:0)
在 $SAVEHIST
的末尾添加 .zshrc
和其他历史参数。
(一些 oh-my-zsh 错误)
它有助于https://www.reddit.com/r/zsh/comments/f29hn4/omz_is_this_a_bug_in_historyzsh/fhf822j