A terminal command logger that records every command across your shell sessions directly into a SQLite database.
- Records every command you run in your terminal
- Stores data in SQLite database (no text files)
- Uses Bun's high-performance native SQLite integration
- Provides command-line utilities for statistics, export, and cleanup
- Easy ZSH integration
- Clone this repository:
git clone https://github.com/fernandobelotto/shellmemory.git
cd shellmemory- Install dependencies:
bun install- Install the CLI globally:
bun run install-cli- Add the ZSH hook to your
.zshrcfile:
# Add this to your .zshrc file
function log_command() {
echo "$(date +%s)|$PWD|$1" | shellmemory log >/dev/null 2>&1
}
autoload -U add-zsh-hook
add-zsh-hook preexec log_command- Restart your shell or source your
.zshrc:
source ~/.zshrcTo see statistics about your most used commands and hourly usage:
shellmemory statsExport your command history in JSON or CSV format:
# Export as JSON (default)
shellmemory export
# Export as CSV
shellmemory export --format=csv
# Export to a file
shellmemory export --format=json --output=commands.jsonRemove old command entries:
# Delete commands older than 30 days (default)
shellmemory clean
# Delete commands older than 7 days
shellmemory clean --older-than=7d
# Delete commands older than 12 hours
shellmemory clean --older-than=12h- Uses Bun's built-in SQLite module (
bun:sqlite) - Enables WAL mode for better performance
- Data stored in
~/.shellmemory/commands.db