There is also Historian [1] for bash, and a bunch of other suggestions in the discussion thread on it on HN [2]
[0]: https://github.com/larkery/zsh-histdb
[1]: https://undertitled.com/2017/04/12/historian-because-please-...
Why? A file is easier to grep (even if you have to pass `-a` to it after the file starts to be in the MBs, right now it is 7.4MB). I love having eternal command history in my zsh, and I wonder if I miss something out by not using SQLite for this.
I use this format:
HISTTIMEFORMAT="[%F %T] "
HISTFILESIZE=1000000000
HISTSIZE=10000000
readonly HISTTIMEFORMAT
readonly HISTFILESIZE
readonly HISTSIZE
export HISTTIMEFORMAT
export HISTFILESIZE
export HISTSIZE
# To always append, never overwrite history
shopt -s histappend
So I get this output: <SEQ> [2020-02-09 07:18:30] <COMMAND>The reason I have the hook reload and sort on each command is so that I can use a dozen screen sessions at once and:
1) they don't overwrite each other's history
2) each session's history is instantly searchable to the others
3) sorting is useful because each session prepends a session ID to the commands, so that Ctrl-R backward search can always hit the current session's commands first. And I can reboot/restart screen and recover history in each session.
(edit: I looked at the zsh-db project the other poster linked, and this does pretty much the same thing just probably slower since there is no DB involved).