2

当我fc -l 1从 shell 运行 a 时,我会从 .zsh_history 中取回完整的历史记录。当我从脚本运行相同的命令时,它只限于最后 30 个。任何想法为什么?

我有以下来自 oh-my-zsh 的 zsh 历史设置

if [ -z $HISTFILE ]; then
   HISTFILE=$HOME/.zsh_history
fi

HISTSIZE=10000
SAVEHIST=10000

setopt appendhistory
setopt extended_history
setopt hist_expire_dups_first
setopt hist_ignore_dups # ignore duplication command history list
setopt hist_ignore_space
setopt hist_verify
setopt inc_append_history
setopt share_history
4

1 回答 1

3

如果您将 aecho $HISTSIZE放入脚本中,则可能是 30。脚本不来源.zshrc,因此脚本不知道您的历史记录设置。

将历史特定选项放入其自己的文件中history.zsh,并从脚本中获取它,并fc -R在任何其他调用之前用于读取历史文件fc

source ${ZDOTDIR-$HOME}/.zsh/history.zsh
fc -R
...
fc -l 1
于 2013-07-29T10:11:18.557 回答