A comprehensive CLI-based monitoring tool that records every command you run in your terminal, along with timestamps and execution duration. Perfect for developers and system administrators who want to analyze their workflows, track repetitive tasks, and generate productivity reports.
- Automatic Command Tracking: Seamlessly logs every command executed in your terminal
- Detailed Metrics: Captures timestamps, execution duration, exit codes, and working directories
- Smart Categorization: Automatically categorizes commands (git, file operations, network, etc.)
- Productivity Reports: Generate insightful reports about your command usage patterns
- Data Visualization: Create beautiful charts and graphs using matplotlib
- Data Persistence: SQLite database ensures your data is safely stored
- Privacy-First: All data stored locally - no online services required
- Export Capabilities: Export your command history to CSV for further analysis
- Search & Filter: Powerful search and filtering capabilities
- Python 3.7 or higher
- pip (Python package installer)
- Clone or download this repository:
git clone <repository-url>
cd command-log-tracker- Install required Python packages:
pip install matplotlib- Make the CLI executable:
chmod +x cmdtrack- (Optional) Add to your PATH:
export PATH="/path/to/command-log-tracker:$PATH"To automatically track all your commands, integrate with your shell:
Add this line to your ~/.bashrc:
source /path/to/command-log-tracker/command_tracker/shell_integration/bashrc_integration.shThen reload your shell:
source ~/.bashrcAdd this line to your ~/.zshrc:
source /path/to/command-log-tracker/command_tracker/shell_integration/zshrc_integration.shThen reload your shell:
source ~/.zshrcOnce integrated, you can temporarily disable or enable tracking:
cmdtrack_disable # Disable tracking
cmdtrack_enable # Enable trackingThe cmdtrack command provides various subcommands for managing and analyzing your command history:
# Show recent commands (default: 20)
cmdtrack history
# Show more commands
cmdtrack history -l 50
# Search for specific commands
cmdtrack history -s "git"# Basic statistics
cmdtrack stats
# Detailed report
cmdtrack stats --detailed# Generate 7-day productivity report
cmdtrack report
# Custom time period
cmdtrack report --days 30
# Include repetitive tasks analysis
cmdtrack report --repetitive# Generate all charts
cmdtrack visualize --all
# Specific chart types
cmdtrack visualize --daily # Daily activity chart
cmdtrack visualize --categories # Category distribution pie chart
cmdtrack visualize --heatmap # Hourly activity heatmap
cmdtrack visualize --top # Top commands bar chart
cmdtrack visualize --trends # Category trends over time
cmdtrack visualize --duration # Execution time distribution
# Custom time period
cmdtrack visualize --all --days 60Charts are saved to ~/.command_tracker/charts/
# Export all commands to CSV
cmdtrack export commands.csv
# Export last 30 days only
cmdtrack export recent.csv --days 30# Log a command manually
cmdtrack log "make build"
# With duration and exit code
cmdtrack log "npm test" -d 12.5 -e 0# View all available command categories
cmdtrack categories# Delete commands older than 90 days
cmdtrack cleanup --days 90
# Force delete without confirmation
cmdtrack cleanup --days 180 --forceCommands are automatically categorized into the following types:
- git: Git version control commands
- file_ops: File operations (ls, cp, mv, etc.)
- text_processing: Text manipulation (grep, sed, awk, etc.)
- network: Network-related commands (ping, curl, ssh, etc.)
- development: Programming and compilation commands
- docker: Docker and container commands
- package_management: Package managers (apt, npm, pip, etc.)
- process_management: Process control (ps, top, kill, etc.)
- database: Database clients and tools
- editors: Text editors (vim, nano, code, etc.)
- And many more...
All data is stored locally in an SQLite database:
- Default location:
~/.command_tracker/commands.db - Charts:
~/.command_tracker/charts/
You can specify a custom database location:
cmdtrack --db /custom/path/commands.db history# See what you worked on today
cmdtrack report --days 1
# Generate visual summary
cmdtrack visualize --daily --days 7# Identify tasks you run frequently
cmdtrack report --repetitive
# Consider creating aliases or scripts for these# Export commands for a specific project
cmdtrack export project_analysis.csv --days 30
# Search for project-specific commands
cmdtrack history -s "my-project" -l 100# See which commands take the longest
cmdtrack stats --detailed
# Visualize execution time distribution
cmdtrack visualize --duration- 100% Local: All data is stored on your local machine
- No Network Calls: The tool never sends data anywhere
- Open Source: Full transparency - review the code yourself
- User Control: Easy to disable, export, or delete your data
command-log-tracker/
├── cmdtrack # Main CLI executable
├── command_tracker/
│ ├── core/
│ │ ├── database.py # SQLite database management
│ │ └── tracker.py # Command tracking logic
│ ├── utils/
│ │ ├── analytics.py # Analytics and reporting
│ │ └── categorizer.py # Command categorization
│ ├── visualizations/
│ │ └── charts.py # Matplotlib visualizations
│ └── shell_integration/
│ ├── track_command.py # Shell hook script
│ ├── bashrc_integration.sh
│ └── zshrc_integration.sh
├── docs/ # Documentation
├── tests/ # Test files
└── examples/ # Example scripts
python -m pytest tests/You can extend the categorizer with custom categories:
from command_tracker.utils.categorizer import CommandCategorizer
categorizer = CommandCategorizer()
categorizer.add_custom_category('my_tools', ['mytool', 'mycommand'])- Verify the integration script is sourced correctly
- Check file permissions are correct (executable)
- Ensure Python 3 is available in your PATH
- Check if tracking is enabled:
cmdtrack_enable - Verify database permissions
- Check for errors in shell output
- The tracking happens asynchronously and shouldn't slow down your shell
- If you notice issues, you can temporarily disable:
cmdtrack_disable - Consider cleaning up old data:
cmdtrack cleanup --days 90
Contributions are welcome! Please feel free to submit issues or pull requests.
This project is open source and available under the MIT License.
Potential features for future versions:
- Web dashboard for visualizations
- Machine learning for command suggestions
- Team collaboration features
- Plugin system for custom analyzers
- Integration with CI/CD pipelines
- Command completion predictions
Built with:
- Python 3
- SQLite
- Matplotlib
- Love for the command line
Happy tracking! May your commands be plentiful and your workflows efficient.