首页 > 解决方案 > 带有时间戳的 zsh 命令行历史记录

问题描述

我正在使用 zsh 4.3.6。我想在命令行历史记录中有时间戳。history -i总是显示当前时间:

> history -i
498  2020-04-27 14:54  history -i
499  2020-04-27 14:54  cat ~/.zsh_history
500  2020-04-27 14:54  exit

似乎时间戳未存储在$HISTFILE

> cat $HISTFILE
ls
zsh --version
history -i

我怎样才能拥有持久的命令行历史时间戳?

谢谢。

标签: command-linezsh

解决方案


setopt EXTENDED_HISTORY     # puts timestamps in the history

或者

setopt extendedhistory

~/.zshrc


推荐阅读