Atuin for zsh shell history in SQLite

Atuin (via Rhet Turnbull) "replaces your existing shell history with a SQLite database". Obviously I had to try this out!

I installed it with Homebrew:

brew install atuin

Then ran this to add it to my .zshrc config:

echo 'eval "$(atuin init zsh)"' >> ~/.zshrc

I restarted my terminal... and now I have a SQLite database full of commands I have run!

The database lives at ~/.local/share/atuin/history.db (I figured that out with this TIL), and can be opened in Datasette.

Screenshot of Datasette showing the history table from the atuin database

Removing the "up" key binding

Atuin hijacks the Ctrl+R shortcut to provide an interactive search window, which I really like:

Screenshot of my terminal history in Atuin

But it also hijacks the Up arrow key, which I didn't like - it interfered with how I usually use that (quickly getting back my previous command and editing it).

This thread in the Atuin issues lead me to a solution - though the fix there put my cursor at the start of the line when I wanted it at the end of the line instead. This StackExchange showed me the fix for that.

I edited my ~/.zshrc file and replaced the atuin bit at the bottom with this:

eval "$(atuin init zsh)"
# Restore original up binding: https://til.simonwillison.net/macos/atuin
autoload -U history-search-end
zle -N history-beginning-search-backward-end history-search-end
bindkey "^[[A" history-beginning-search-backward-end

Created 2022-04-26T11:53:21-07:00, updated 2022-04-26T12:26:03-07:00 · History · Edit