hy is a small Rust CLI for recording and searching shell history in plain text log files under ~/.logs/.
It is meant to replace ad-hoc precmd or PROMPT_COMMAND snippets with a stable hy-managed hook while keeping the history files easy to inspect with grep, awk, or sed.
- Records shell commands into daily text files such as
~/.logs/bash-history-2026-04-19.log - Searches command text with
hy <query> - Filters by working directory using path expansion or partial matches with
hy --folder <path> - Supports
--today,--since <days>,--limit <n>, and--json - Supports case-insensitive search with
-i/--ignore-caseorHY_IGNORE_CASE=1 - Installs managed shell hooks with
hy install bashorhy install zsh - Reads the newer escaped-TSV format exactly and older space-delimited logs on a best-effort basis
The published crate name is historion, but the installed command is hy.
Install from crates.io:
cargo install historionThen run:
hy --helpInstall from the latest GitHub release:
- Open https://github.com/srgrn/historion/releases/latest
- Download the archive for your platform:
hy-<version>-linux-x86_64.tar.gzhy-<version>-macos-x86_64.tar.gzhy-<version>-windows-x86_64.zip
- Extract the archive
- Put the
hybinary somewhere on yourPATH
Example on Linux or macOS after extracting:
chmod +x hy
mv hy ~/.local/bin/hyBuild locally from source:
cargo buildInstall the local checkout into Cargo's bin directory:
cargo install --path . --forceIf you do not want hy on your PATH, set HY_BIN in your shell before loading the hook:
export HY_BIN="$HOME/.cargo/bin/hy"To override the log directory, set HY_LOG_DIR. Absolute paths are used as-is. Relative paths are resolved from your home directory.
export HY_LOG_DIR="$HOME/history-logs"Preview the generated hook:
hy init zsh
hy init bashInstall the managed hook into your rc file:
hy install zsh
hy install bashhy install writes a marked block into ~/.zshrc or ~/.bashrc and updates that same block if you run it again. It does not need the old inline history snippet.
Search for commands containing a word:
hy cargoSearch only within the current directory tree:
hy --folder .Search by a partial folder name anywhere in the logged cwd:
hy --folder srcCombine text search and folder filtering:
hy cargo --folder .Make search case-insensitive:
hy cargo --ignore-case
HY_IGNORE_CASE=1 hy --folder srcLimit to recent logs:
hy cargo --today
hy cargo --since 7Get machine-readable output:
hy cargo --jsonrecord is meant for shell hooks, but it can also be called directly:
hy record --cwd "$PWD" --command "cargo test" --history-id 42 --shell zshhy stores one escaped-TSV record per line:
2026-04-19T10:23:45+0100 /home/zimbl/project cargo test --lib
2026-04-19T10:25:02+0100 /home/zimbl/project/src rg history
Rules:
- Field order is
timestamp<TAB>cwd<TAB>command - Tabs, newlines, and backslashes inside values are escaped
- Files stay readable and grep-friendly
- Duplicate suppression metadata is kept in a separate hidden state file, not inside the searchable log line
You can still use plain shell tools directly:
grep cargo ~/.logs/bash-history-*.logIf you use HY_LOG_DIR, point your shell tools there instead.
If you previously had a custom precmd or PROMPT_COMMAND snippet that wrote directly to ~/.logs, the migration path is:
- Remove the old shell snippet from your rc file.
- Install
hy. - Run
hy install zshorhy install bash. - Reload your shell.
Old space-delimited log files are still searchable, but only on a best-effort basis because the original format is ambiguous when paths or commands contain spaces. New hy-written logs use the structured escaped-TSV format and are parsed exactly.
Run the full test suite:
cargo testThe repository also keeps a LESSONS.md file with implementation decisions and gotchas that should persist across future tasks.