Never lose
a command
again.

A high-performance terminal command logger that records every command across all your shell sessions into a SQLite database.

user@machine:~

Key Features

shellmemory combines a simple setup with powerful features to help you track and analyze your terminal usage

Command History

Record every command across all terminal sessions, preserving context and working directory

SQLite Storage

Store all command history in a performant SQLite database with Bun's native integration

Insights & Analytics

Generate statistics about your most used commands, productivity patterns, and command history

Flexible Export

Export your command history in JSON or CSV format for external analysis or backup

Lightweight & Fast

Built with Bun for minimal overhead and blazing-fast performance

Smart Cleanup

Easily manage database size with configurable cleanup options for old commands

How It Works

shellmemory integrates seamlessly with your shell to capture and organize your command history

1

ZSH Hook

A simple hook added to your .zshrc captures each command you run

2

SQLite Storage

Commands are stored in a SQLite database with timestamp and directory context

3

CLI Tools

Use shellmemory commands to view statistics, export data, or clean old entries

Installation

Get started with shellmemory in just a few steps

1 Install from NPM

installation
npm install -g shellmemory

2 Add to your .zshrc

~/.zshrc
# 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

3 Reload your shell

terminal
source ~/.zshrc

That's it! shellmemory is now recording your commands.

Usage Examples

Simple commands to access your command history data

View Command Statistics

Command
shellmemory stats
Output
Most Used Commands: git commit -m : 143 times npm run dev : 89 times ls : 76 times cd : 62 times git push : 58 times Command Activity by Hour: 09:00 - 12:00 : ████████████ 32% 12:00 - 15:00 : ██████████ 26% 15:00 - 18:00 : ███████████ 29% 18:00 - 21:00 : █████ 13% Total Commands: 1,243 First Command: 2023-06-12 Database Size: 2.4 MB

Export Command History

Command
shellmemory export --format=json --output=commands.json
Output
Exporting command history... [ { "id": 1, "command": "git clone https://github.com/example/repo.git", "directory": "/Users/username/Projects", "timestamp": 1686581324 }, { "id": 2, "command": "cd repo", "directory": "/Users/username/Projects", "timestamp": 1686581330 }, ... ] Export complete: 1,243 commands exported to commands.json

Clean Old Commands

Command
shellmemory clean --older-than=30d
Output
Cleaning commands older than 30 days... Commands before cleanup: 1,243 Commands deleted: 213 Commands remaining: 1,030 Database size before: 2.4 MB Database size after: 2.1 MB Cleanup complete!

Search Command History

Command
shellmemory search "docker"
Output
Searching for commands containing "docker"... 2023-08-12 09:45:23 [/Users/username/Projects/app] docker-compose up -d 2023-08-12 10:32:15 [/Users/username/Projects/app] docker ps 2023-08-13 14:20:05 [/Users/username/Projects/app] docker logs -f web 2023-08-15 16:45:32 [/Users/username/Projects/app] docker-compose down Found 12 commands matching "docker"

Why shellmemory?

shellmemory offers significant benefits over traditional shell history

Standard shell history

  • Limited history size (typically 1000 commands)

  • History stored in text files, easily corrupted

  • No context about working directory

  • No analytics or insights about usage

  • History separate for each shell session

  • Limited search capabilities

shellmemory advantages

  • Unlimited history size (constrained only by disk space)

  • Robust SQLite database storage with WAL mode

  • Records working directory for every command

  • Rich analytics and usage statistics

  • Unified history across all terminal sessions

  • Powerful search with filtering options

Ready to start logging?

Never lose track of your command history again. Install shellmemory today and take control of your terminal.

Get Started Now Star on GitHub