For what it’s worth, zsh history has time and duration in its history mechanism with setopt extendedhistory.
% sleep 7
% echo this echo should take 0 seconds
this echo should take 0 seconds
% fc -l -i -D -2
4793 2021-05-08 10:58 0:07 sleep 7
4794 2021-05-08 10:58 0:00 echo this echo should take 0 seconds
fc: access to shell history, stands for “fix command” as without arguments it opens the previous command in an editor and runs the saved result
-l: list instead of “fix”
-i: ISO datetime version of -d date flag
-D: duration
-2: not a flag, just sets the history cursor start to 2 before the end (using 0 as start prints all history)
I can also recommend setopt incappendhistorytime, which appends to the history file after every command completes rather than when the shell terminates. I find it’s often useful to have immediate access to recent history in new shells.
This is really cool! I’ve often thought about doing something similar, recording even more context (recording the binaries in $PATH, ptrace’ing the commands that are run in order to record the content of directories that are touched…) in the hope of attempting to build a fancy machine-learning-based command suggestion plugin for zsh. Never took the time to even begin though, so it’s pretty cool to see someone actually building something pretty close!
I used to use https://github.com/larkery/zsh-histdb but had problems with the merging of the sqlite database. I wrote my own (also written in rust https://github.com/AlexanderThaller/histdb-rs) using one csv file per machine and syncing via git which is working pretty well for me. I didn’t have a need for encryption as I use a private git server for the history files but will definitely checkout atuin as an alternative!
This is amazing, I have to see how I can migrate from zsh-histdb to atuin. I think whats cool about zsh-histdb is that it only needs zsh + sqlite, but on the otherhand if I’m already able to install sqlite why not go one step further of course! Only thing I could be hoping for is atuin and zsh-histdb supporting each others sqlite db in the future.
Glad you like it! I think if you could export zsh-histdb into a zsh extended history file then that could be imported, but some of the data would be lost. Otherwise the schema Atuin uses isn’t that complicated, so some kind of sqlite csv import could be done before Atuin supports importing from zsh-histdb
Only thing I could be hoping for is atuin and zsh-histdb supporting each others sqlite db in the future.
I’ve heard quite a few people mentioning zsh-histdb, so I think this would definitely be worth while! I’ll open an issue to track this
Maybe worthy of note is the old Reactive Keyboard system:
Darragh, J. J., Witten, I. H., & James, M. L. (1990). The Reactive Keyboard: a predictive typing aid. Computer, 23(11), 41–49. doi:10.1109/2.60879
I’m not sure if there is a way to integrate this into a Unix terminal emulator smoothly. Integration via shell/vim/emacs/etc. might be better..but there is both more than one source of text and more than one place of applicability.
For what it’s worth, zsh history has time and duration in its history mechanism with
setopt extendedhistory
.fc
: access to shell history, stands for “fix command” as without arguments it opens the previous command in an editor and runs the saved result-l
: list instead of “fix”-i
: ISO datetime version of-d
date flag-D
: duration-2
: not a flag, just sets the history cursor start to 2 before the end (using 0 as start prints all history)I can also recommend
setopt incappendhistorytime
, which appends to the history file after every command completes rather than when the shell terminates. I find it’s often useful to have immediate access to recent history in new shells.This is really cool! I’ve often thought about doing something similar, recording even more context (recording the binaries in $PATH, ptrace’ing the commands that are run in order to record the content of directories that are touched…) in the hope of attempting to build a fancy machine-learning-based command suggestion plugin for zsh. Never took the time to even begin though, so it’s pretty cool to see someone actually building something pretty close!
Thanks! Haha I’ve had similar thoughts - it would be great to record way more data than just the obvious and then make the suggestions really good!
Right now it’s all pretty naive, but I hope people still find it useful
I used to use https://github.com/larkery/zsh-histdb but had problems with the merging of the sqlite database. I wrote my own (also written in rust https://github.com/AlexanderThaller/histdb-rs) using one csv file per machine and syncing via git which is working pretty well for me. I didn’t have a need for encryption as I use a private git server for the history files but will definitely checkout atuin as an alternative!
This is amazing, I have to see how I can migrate from zsh-histdb to atuin. I think whats cool about zsh-histdb is that it only needs zsh + sqlite, but on the otherhand if I’m already able to install sqlite why not go one step further of course! Only thing I could be hoping for is atuin and zsh-histdb supporting each others sqlite db in the future.
Glad you like it! I think if you could export zsh-histdb into a zsh extended history file then that could be imported, but some of the data would be lost. Otherwise the schema Atuin uses isn’t that complicated, so some kind of sqlite csv import could be done before Atuin supports importing from zsh-histdb
I’ve heard quite a few people mentioning zsh-histdb, so I think this would definitely be worth while! I’ll open an issue to track this
Maybe worthy of note is the old Reactive Keyboard system:
Darragh, J. J., Witten, I. H., & James, M. L. (1990). The Reactive Keyboard: a predictive typing aid. Computer, 23(11), 41–49. doi:10.1109/2.60879
I’m not sure if there is a way to integrate this into a Unix terminal emulator smoothly. Integration via shell/vim/emacs/etc. might be better..but there is both more than one source of text and more than one place of applicability.