logoalt Hacker News

apodiktoday at 8:01 AM3 repliesview on HN

is there a particular reason why i'd want sqlite-backed shell history? i mean sure it works but why not a text file? (which i'd assume is somewhat faster because you can just append)

i guess you could say it's because you may want dates for each command but for that you can just use a CSV or TSV file no?

does it have to do with the searching?


Replies

ptsptstoday at 4:13 PM

I have a regular Bash shell history with about 750 000 entries on an SSD on a modern laptop, and would take about 1 second for Bash to load 1 million entries. The startup delay and the memory usage is noticeable.

Storing the shell command history in a database instead of the memory of each interactive Bash shell, it would make Bash start up faster, and also use less memory.

vladvasiliutoday at 8:35 AM

In my case, I use Atuin. It has a concept of "context" so you can easily search the history for commands related to your current directory / project / etc. See [0] for some examples.

Now, I admit I don't use these that often, but they can be useful.

It also does stats and whatnot based on the history. I've never looked at those.

[0] https://docs.atuin.sh/latest/guide/advanced-usage/

fpolingtoday at 8:38 AM

SQLite gives indexes that makes searching and locating previous entries much faster. This is relevant when the history is over 100K entries and one wants to avoid duplicates in history files.

show 1 reply