historic stores your terminal commands in a local SQLite database and gives you a fuzzy-searchable TUI to pull them back into your prompt, across sessions, windows and panes.
- Fuzzy search through everything you've saved
- Session-aware: detects tmux session, window and pane
- Persistent: one SQLite database, safe to use from many terminals at once
- Standalone: works fine without a multiplexer
Build from source (requires Rust):
git clone https://github.com/n3tw0rth/historic.git
cd historic
cargo install --path .Or, with just: just install.
historic # open the picker
historic add <command> # save a commandBind the picker to Ctrl+T and insert the selection at the cursor:
__historic__() {
local selected
selected="$(historic | sed 's/\x1b\[[0-9;?]*[a-zA-Z]//g')"
READLINE_LINE="${READLINE_LINE:0:$READLINE_POINT}$selected${READLINE_LINE:$READLINE_POINT}"
READLINE_POINT=$(( READLINE_POINT + ${#selected} ))
}
bind -x '"\C-t":"__historic__"'Save every command automatically after it runs:
__historic_add__() {
local entry
entry="$(HISTTIMEFORMAT= builtin history 1)"
# Skip the shell's first prompt, and any prompt where history didn't change
# (an empty line, Ctrl+C or a space-prefixed command).
if [[ ${__historic_last__+set} && $entry != "$__historic_last__" ]]; then
historic add -- "$(sed '1s/^ *[0-9]*[* ] //' <<<"$entry")"
fi
__historic_last__=$entry
}
PROMPT_COMMAND="__historic_add__${PROMPT_COMMAND:+;$PROMPT_COMMAND}"Put both snippets at the end of ~/.bashrc, so nothing that runs later replaces PROMPT_COMMAND. Then open a new shell. Panes and terminals that were already open won't have the hook until you run source ~/.bashrc in them.
Inside tmux, each pane has its own list. The picker shows every command saved from that pane, whichever directory you ran it in. Outside tmux, every terminal shares one list. The hook saves what bash adds to its history. With HISTCONTROL=ignorespace or ignoreboth (the Ubuntu default), commands that start with a space aren't saved.
The picker opens ready to search: just type, then press Enter. Space-separated words can match in any order, and the search is case-sensitive only if you type an uppercase letter.
| Key | Action |
|---|---|
| Enter | Pick command |
| ↑ / ↓, Ctrl+P / Ctrl+N | Move selection |
| Ctrl+U / Ctrl+W | Clear search / delete last word |
| Esc | Stop searching and browse |
| j / k | Move selection (browsing) |
| i or / | Start searching again (browsing) |
| q or Esc | Quit (browsing) |
| Ctrl+C | Quit |
Everything lives in ~/.config/historic/historic.db (or your platform's config directory). Nothing leaves your machine.