AskGPT CLI
A powerful command-line interface that leverages Claude 3.5 Sonnet to generate and explain Linux shell commands from natural language queries. Simply describe what you want to do, and AskGPT will provide the exact command along with a clear explanation.
Key Features
- Natural language to shell command translation
- Context-aware command generation based on your current environment
- Command history integration for smarter suggestions
- Support for piped input data
- Maintains conversation history for more relevant responses
- Detailed explanations for every suggested command
Prerequisites
- Python 3.7 or higher
- AWS credentials
- Bash shell environment
Installation
- Install required Python packages:
pip install boto3 humanize
- Copy the script to your system:
sudo cp askgpt.py /usr/local/bin/askgpt sudo chmod a+x /usr/local/bin/askgpt
- Configure bash history integration by adding this line to your
~/.bashrc:
export PROMPT_COMMAND='history -a'
- Reload your bash configuration:
Usage
Basic Query
Simply run the command without arguments to enter interactive mode:
Direct Query
Provide your query directly as an argument:
askgpt "find all text files modified in the last 24 hours"Piped Input
You can pipe command output to AskGPT for explanation or further processing:
ps axuw | grep init | askgpt
Or add a specific query for the piped data:
ps axuw | grep init | askgpt "explain what these numbers mean"
Examples
- Finding files:
askgpt "find all PNG files larger than 1MB"- System monitoring:
askgpt "show me CPU usage for all processes sorted by usage"- Text processing:
cat log.txt | askgpt "extract all IP addresses"
Configuration
The tool uses your AWS credentials for API access. If you want support for more APIs, let me know (or propose a pull request).
Contributing
Feel free to submit issues and pull requests to improve AskGPT CLI.