9 Comments
Jan 21Liked by Thorsten Ball

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

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

Expand full comment

Love it, thanks a lot!

Expand full comment

how did you set up `ctrl+r` to execute `fzf` on your zsh history? i couldn't find anything in our dotfiles repo :)

Expand full comment

ctrl r definitely feels like a super power, it's super cool

Expand full comment