I am not sure if I fully understand how zsh stores its history. Example line:
: 1458291931:0;ls -l
I guess we have here:
but what this mystical 0 in between means?
This is the so-called *extended history format, which is enabled by the EXTENDED_HISTORY
shell option. The second number (the "mystical 0") is the duration of the command. "0" either means that the command finished quickly or - depending on your settings - that the duration is not saved. If either of the shell options INC_APPEND_HISTORY
or SHARE_HISTORY
is enabled (you can check this with setopt | grep -E '^(incappend|share)history$'
), then zsh
will write the history entry to the history file immediately after confirming the command. The duration will be saved as "0" in that case.
If you want to make use of the duration metric while still saving the history to file during shell sessions, you can set the option INC_APPEND_HISTORY_TIME
, in which case zsh
will wait for command completion before writing the entry. Obviously this will otherwise behave like INC_APPEND_HISTORY
.
Note: only one of the options INC_APPEND_HISTORY
, INC_APPEND_HISTORY_TIME
and SHARE_HISTORY
should be active
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With