A high-performance terminal command logger that records every command across all your shell sessions into a SQLite database.
shellmemory combines a simple setup with powerful features to help you track and analyze your terminal usage
Record every command across all terminal sessions, preserving context and working directory
Store all command history in a performant SQLite database with Bun's native integration
Generate statistics about your most used commands, productivity patterns, and command history
Export your command history in JSON or CSV format for external analysis or backup
Built with Bun for minimal overhead and blazing-fast performance
Easily manage database size with configurable cleanup options for old commands
shellmemory integrates seamlessly with your shell to capture and organize your command history
A simple hook added to your .zshrc captures each command you run
Commands are stored in a SQLite database with timestamp and directory context
Use shellmemory commands to view statistics, export data, or clean old entries
Get started with shellmemory in just a few steps
npm install -g shellmemory
# 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
source ~/.zshrc
That's it! shellmemory is now recording your commands.
Simple commands to access your command history data
shellmemory stats
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
shellmemory export --format=json --output=commands.json
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
shellmemory clean --older-than=30d
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!
shellmemory search "docker"
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"
shellmemory offers significant benefits over traditional 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
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
Never lose track of your command history again. Install shellmemory today and take control of your terminal.
Get Started Now Star on GitHub