Skip to content

fernandobelotto/shellmemory

Repository files navigation

shellmemory

A terminal command logger that records every command across your shell sessions directly into a SQLite database.

Features

  • 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

Installation

  1. Clone this repository:
git clone https://github.com/fernandobelotto/shellmemory.git
cd shellmemory
  1. Install dependencies:
bun install
  1. Install the CLI globally:
bun run install-cli
  1. Add the ZSH hook to your .zshrc file:
# 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
  1. Restart your shell or source your .zshrc:
source ~/.zshrc

Usage

Viewing Command Statistics

To see statistics about your most used commands and hourly usage:

shellmemory stats

Exporting Command History

Export 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.json

Cleaning Old Commands

Remove 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

Technical Details

  • Uses Bun's built-in SQLite module (bun:sqlite)
  • Enables WAL mode for better performance
  • Data stored in ~/.shellmemory/commands.db

License

Apache License 2.0

About

A terminal command logger that records every command across your shell sessions directly into a SQLite database.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published