Discussion about this post

User's avatar
Lars Håkedal's avatar

The oldest entry in my history.sql is dated Wed Oct 17 13:07:38 CEST 2012. It's a bit of a hack, using PROMPT_COMMAND to push entries into this table:

CREATE TABLE history (pid INTEGER, host TEXT, date INTEGER, cwd TEXT, starttime INTEGER, command TEXT);

It's pretty much a gross hack that started with "history 1" and grew to include this and that, needed some formatting, needed a tmpfile (though probably not, really) and then squeeze it into the db.

export PROMPT_COMMAND='printf "%s^A%s^A%s^A%s^A%s\n" "$$" "$(hostname)" "$(date +%s)" "$(pwd)" "$(HISTTIMEFORMAT="%s^A" history 1 | sed "s/^ *[^ ]* *//g")" > /tmp/hinser;sqlite3 -separator ^A ~/someplace/bash_history.sql ".import /tmp/hinser history"'

The ^As are literal 001 to act as separators, I tried a number of other ways of separating the fields, ended up with ^A since that character seldom shows up in cmdlines or in any of the other fields.

Currently there are 198K lines of history, dumped to text it amounts to about 20MBs of text.

Expand full comment
Surya's avatar

Love atuin ! One of the better shell feature replacements i have come to appreciate this past year

Expand full comment
7 more comments...

No posts