atuin

May 08, 2022

https://github.com/ellie/atuin

Atuin replaces your existing shell history with a SQLite database, and records additional context for your commands. Additionally, it provides optional and fully encrypted synchronisation of your history between machines, via an Atuin server.

I'm going to try it out, because I really want my history in a database instead of the janky history file.

Installs https://github.com/rcaloras/bash-preexec

atuin import bash imported my bash history

$ atuin stats all
+---------------------+----------+
| Statistic           | Value    |
+---------------------+----------+
| Most used command   | git pull |
+---------------------+----------+
| Commands ran        |     8449 |
+---------------------+----------+
| Unique commands ran |     5560 |
+---------------------+----------+

looks about right.

Stores the db at ./.local/share/atuin/history.db, and indeed it's a simple queryable sqlite database. The config file at ~/.config/atuin/config.toml will let you change the path as well as some other stuff, but I'm just gonna leave it at the default state for now.

Would like to use litestream to back it up to s3.

Is it still echoing to ~/.bash_history? Yup:

$ tail ~/.bash_history
#1650679383
git co master
#1650679389
git branch -D exclude-take-3
#1650679393
git pull
#1650985607
ls testing

$ sqlite3 ./.local/share/atuin/history.db 'select command from history order by timestamp desc limit 5;'
sqlite3 ./.local/share/atuin/history.db 'select command from history order by timestamp desc limit 5;'
sqlite3 ./.local/share/atuin/history.db -c 'select command from history order by timestamp desc limit 5;'
tail ~/.bash_history
ls testing
tail ~/.bash_history

Has search subcommand if you don't want to just query the db

this person has set up litestream replication for their atuin db, maybe I can crib from them.

replaces my fzf ctrl-r binding with something a bunch worse

Seems like you need to prepend any query with *; atuin search jq shows no results but atuin search '*jq' yields what I'd expect.

ah ha! go to ~/.config/atuin/config.toml and set search_mode to fuzzy. docs here:

## which search mode to use
## possible values: prefix, fulltext, fuzzy
search_mode = "fuzzy"
↑ up