ZSH Expanded History Error

ZSH Expanded History Error

While making the official switch from bash to ZSH,  (https://www.kali.org/news/kali-2020-3-release/ , https://www.bleepingcomputer.com/news/linux/kali-linux-20203-begins-journey-of-replacing-bash-with-zsh/ ) I wanted to enable extend history options for date timestamps without going full blown into OMZSH. Why? Well, coursework necessitated this change and the time stamps can be rather useful.

Extended_history: Save each command’s beginning timestamp (in seconds since the epoch) and the duration (in seconds) to the history file.  The format of this prefixed data is:  ‘: <beginning time>:<elapsed seconds>;<command>’.

Simple enough, just edit you r~/.zshrc file right? Not so fast.

setopt inc_append_history
setopt extended history
HISTTIMEFORMAT="[%F %T] " 

After these changes I could see that my .zsh_history file was being updated with epoch time stamps appropriately, however I couldn't call this data from the command line with the -E option, as intended.

─$ history -E 
fc: event not found: -E

fc: event not found: -E  .... Hum.

After twenty-five minutes of research, and a lot of learning, I found that the history file is just an alias to the FC command. And, if you look carefully within .zshrc, there is a hard coded alias for history:

alias history="history 0"

Duh-hu. Just comment this out, resource and relaunch zsh and the issue should be fixed.

.zshrc file with a commented out history alias
#alias history="history 0"

# from within ~/
source .zshrc
exec zsh

Issue resolved. I hope that helps someone.

For more details on the options in your zshrc file: http://zsh.sourceforge.net/Doc/Release/Options.html#Options

FC command? : https://shapeshed.com/unix-fc/