Hacker News new | ask | show | jobs
by outcoldman 893 days ago
I keep my shell history in sqlite database since 2017. Around 120k records at this point. Never synced history from the work laptops. Only personal history.

In 2017 wrote my own bash script (later optimized for zsh) to just record everything in sqlite with hooks on prompt. [1]

I mostly work right now on Mac, don't need to support Linux anymore, so wrote an app for Mac, that syncs the history over iCloud, and has a GUI interface. [2]

Anyway, storing years of shell history somewhere, where you can do complex searches, and actually find some magic command you run a few years ago, is priceless.

- [1] https://www.outcoldman.com/en/archive/2017/07/19/dbhist/

- [2] https://loshadki.app/shellhistory/

1 comments

Do you know any way to accomplish the same thing but keeping the history in plaintext? Would love to still be able to run SQL over it.
Couldn't you just point DuckDB or a similar tool to the history file?
.. i replied to the main thread, if you want give my bash script a try. each project history is in its own named file .. https://gist.github.com/appsmatics/ff27e885460bd345eabe1c5f7...
Write to two places in the hook?