A natural language interface for terminal commands
Project description
CommandRex 🦖
A natural language interface for terminal commands.
Description
CommandRex allows you to interact with your terminal using natural language. Simply tell CommandRex what you want to do, and it will translate your request into the appropriate terminal command. It's like having an AI assistant for your command line!
Features
- Natural Language Command Translation: Convert plain English to precise terminal commands
- Command Explanations: Get detailed explanations of what commands do and how they work
- Safety Analysis: Automatic detection of potentially dangerous commands with warnings
- Cross-Platform Support: Works on Windows, macOS, and Linux
- Interactive Mode: Real-time command translation and execution
- Educational Breakdowns: Learn terminal commands through component-by-component explanations
- Secure API Key Management: Your OpenAI API key is stored securely in your system's keyring
Requirements
- Python 3.10 or higher
- OpenAI API key (get one at https://platform.openai.com/api-keys)
- Internet connection for API communication
Installation
From PyPI (Recommended)
pip install commandrex
From Source
git clone https://github.com/siddhantparadox/commandrex-cli.git
cd commandrex-cli
pip install -e .
Using Poetry
git clone https://github.com/siddhantparadox/commandrex-cli.git
cd commandrex-cli
poetry install
Usage
Interactive Mode
Start the interactive terminal interface:
python -m commandrex run
This launches CommandRex in interactive mode, where you can type natural language requests and see them translated into terminal commands.
For more detailed information:
python -m commandrex run --debug
Translate a Command
Translate a natural language query to a shell command:
python -m commandrex translate "list all files in the current directory including hidden ones"
Add the --execute flag to automatically execute the translated command:
python -m commandrex translate "create a new directory called projects" --execute
Explain a Command
Get a detailed explanation of a shell command:
python -m commandrex explain "grep -r 'TODO' --include='*.py' ."
This will provide:
- A general explanation of what the command does
- Breakdown of each component
- Safety assessment
- Related commands and examples
API Key Management
Reset your stored API key:
python -m commandrex --reset-api-key
Other Options
View version information:
python -m commandrex --version
Use a different OpenAI model:
python -m commandrex run --model gpt-4o
Enable debug mode:
python -m commandrex run --debug
See help:
python -m commandrex run --help
Examples
Here are some examples of natural language queries you can use with CommandRex:
- "Show me all running processes"
- "Find all text files containing the word 'important'"
- "Create a backup of my documents folder"
- "Show disk usage for the current directory"
- "Kill the process running on port 3000"
- "Extract the contents of archive.zip to the folder 'extracted'"
- "Show me the last 50 lines of the error log"
How It Works
CommandRex uses OpenAI's language models to translate your natural language requests into terminal commands. It provides context about your operating system, shell environment, and common command patterns to generate accurate and safe commands.
The application:
- Analyzes your request
- Generates an appropriate command
- Explains what the command does
- Checks for potential safety issues
- Executes the command if requested
Security
CommandRex takes security seriously:
- Your API key is stored securely in your system's keyring
- Commands are analyzed for potential security risks before execution
- Potentially dangerous commands are clearly marked with warnings
- You always have the final say on whether to execute a command
- No data is stored or shared beyond what's needed for API communication
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file commandrex-0.1.0.tar.gz.
File metadata
- Download URL: commandrex-0.1.0.tar.gz
- Upload date:
- Size: 39.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.13.0 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01af03cc5033d5482929848569d6d72588d58ee7d78d9be6d542e9651c65be8b
|
|
| MD5 |
8a3fd39253663249dd7fc15eaf55f519
|
|
| BLAKE2b-256 |
9256dbcee81bc672aa04be21534b23f7d51b1895ec1b009645f0bca3dc26451b
|
File details
Details for the file commandrex-0.1.0-py3-none-any.whl.
File metadata
- Download URL: commandrex-0.1.0-py3-none-any.whl
- Upload date:
- Size: 49.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.13.0 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d00d5d6cd0891ce71aabb70299db2185beb7353da679fd65d617a39d6072a98
|
|
| MD5 |
1a33709f900f14245bf5b43363dd9216
|
|
| BLAKE2b-256 |
1915566e228a8caeed7f0bd2a46ffcfe6f30e92fd035fab3d8c4ea4447cad3d9
|