https://github.com/ckampfe/shelldb
Record your zsh command history to a SQLite database
https://github.com/ckampfe/shelldb
database history shell sqlite zsh
Last synced: 3 months ago
JSON representation
Record your zsh command history to a SQLite database
- Host: GitHub
- URL: https://github.com/ckampfe/shelldb
- Owner: ckampfe
- License: bsd-3-clause
- Created: 2024-10-09T00:52:15.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-02T21:03:50.000Z (over 1 year ago)
- Last Synced: 2025-03-02T22:19:04.562Z (over 1 year ago)
- Topics: database, history, shell, sqlite, zsh
- Language: Rust
- Homepage:
- Size: 39.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# shelldb
Record your `zsh` command history to a SQLite database.
## installation
First, [install Rust](https://www.rust-lang.org/tools/install).
Then:
```sh
$ git clone https://github.com/ckampfe/shelldb.git
$ cd shelldb
$ cargo install --path . --force
$ echo "source /location/of/this_repo/shelldb.sh" >> ~/.zshrc
$ source ~/.zshrc
```
## options
The environment variable `SHELLDB_HISTORY_DB_PATH` allows you to override the default and set a custom history database location. You should set it in your `.zshrc` before sourcing `shelldb.sh`, and it should look like: `/path/to/your/history.db`.
Run `shelldb -h` to see the other options if you're curious about how `shelldb` works.
## how
`shelldb` hooks in to 2 `zsh` hooks, `preexec` and `precmd` as described [here](https://zsh.sourceforge.io/Doc/Release/Functions.html). The first phase, during `preexec`, records the command, the working directory the command was executed in, and the start time. This first phase returns an id unique to that command that the subsequent `precmd` phase references to then set the exit code and the finish time when the command finishes executing.
## motivation
This project is like [Atuin](https://github.com/atuinsh/atuin) but _only_ records shell history.
I have no dislike of `Atuin`, but `Atuin` has a lot of features I don't need.
To that end, `shelldb` is:
1. _only_ shell history recording, nothing else
2. a minimal implementation I can 100% understand top-to-bottom
3. only available for `zsh`, because that's what I use
## is it any good?
yes.