Show HN: Historian – A simple shell history tool

3 days ago 2

UI

Shell history manager with SQLite backend.

demo.mov
make build make install # install hook so historian can intercept and store commands historian hook --install --shell zsh # source session or make a new window source ~/.zshrc # import existing shell history historian import -history ~/.zsh_history # Example output: Imported 0 commands from /Users/schachte/.zsh_history (10078 parsed, 10078 skipped as duplicates)
historian init [--config PATH] [--db PATH] [--force] [--debug]
historian log --command "ls -la" [--exit CODE] [--session ID] [--phase start|end|complete] [--id ID]
# Interactive search historian search # Raw output historian search --raw [--query TEXT] [--limit N] [--session ID] [--cursor POS] [--debug]
# Print hook for current shell historian hook # Install hook historian hook --install [--shell bash|zsh] [--rc PATH]
historian import [--history PATH] [--user USER] [--host HOST] [--session ID]

Default database location:

~/.local/share/historian/history.sqlite3

Schema:

CREATE TABLE commands ( id INTEGER PRIMARY KEY, command TEXT NOT NULL, run_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, finished_at TIMESTAMP, duration_ms INTEGER, username TEXT NOT NULL, hostname TEXT NOT NULL, cwd TEXT NOT NULL, exit_code INTEGER, session_id TEXT );

Query examples:

sqlite3 ~/.local/share/historian/history.sqlite3 "SELECT * FROM commands ORDER BY run_at DESC LIMIT 10;" sqlite3 ~/.local/share/historian/history.sqlite3 "SELECT command, run_at FROM commands WHERE command LIKE '%git%';"
Read Entire Article