Hacker News

Stinkpot: SQLite-backed shell history

Introduction

Stinkpot is an SQLite-backed shell-history searcher for bash. Stinkpot is a much tinier atuin. I have been using atuin for a while, but I don't use most of its features: the sync server, atuin AI, dotfiles manager, script manager or the KV store. While sync is interesting, my machines have very different setups and I tend to run very different commands on them. My only use case for atuin was the session agnostic history management, and the searcher TUI. Stinkpot provides these while being about 400 lines of Go. Stinkpot is a tiny turtle species apparently, hence the name.

stinkpot -------- _ _
 / \ _ (_\/\_/\/_)
/\/ \/\ \/\_/\/ \/_\/ " "

Development

To build:

go build -o stinkpot .

Usage

If you use home-manager for NixOS, stinkpot has a home-manager module:

home-manager.users. = {
  imports = [ ./home.nix inputs.stinkpot.homeManagerModules.default ];
};

If not, just call eval the init script in your .bashrc:

eval "$(stinkpot init)"

Start by importing your existing bash history into stinkpot:

stinkpot import

Then hit Ctrl+R at your shell to trigger reverse search:

> search history...
1s vim flake.nix
3m redis-server
3m jj l
35m jj show m
36m jj git fetch
39m cd
40m vim readme.txt
788 matches ยท โ†‘/โ†“ move ยท enter accept ยท esc cancel

Hit Tab/Enter to accept the selection, then hit Enter again to execute. The history database is stored in ~/.local/share/stinkpot. If upgrades break the DB, just delete it and run the import command.

SQLite-backed shell history
Go 82.5% Nix 17.5%
Signed-off-by: oppiliappan

Speeds up reverse search, the SQLite plan now uses covering index instead of temp b-tree for order-by.
Signed-off-by: oppiliappan

Comments

No comments yet. Start the discussion.