Overview
qcmd is a powerful command-line tool that generates shell commands using AI models via Ollama. Simply describe what you want to do in natural language, and qcmd will generate the appropriate command.
Simplicity
No more memorizing complex commands. Just describe what you want to do, and let AI generate the right command for you.
Intelligence
Leverages local language models to understand your intent and generate accurate shell commands.
Error Fixing
Automatically analyzes errors and suggests fixes, making the command-line experience smoother.
Installation
Before installing qcmd, ensure you have:
- Python 3.6 or higher
- Ollama installed and running
- At least one language model pulled (e.g., qwen2.5-coder:0.5b)
Installation Steps
There are two ways to install qcmd:
Option 1: Install from PyPI (Recommended)
pip install ibrahimiq-qcmd
This will install the package and make the qcmd command available in your PATH.
Option 2: Install from Source
git clone https://github.com/aledanee/qcmd.git
cd qcmd
chmod +x setup-qcmd.sh
./setup-qcmd.sh
The setup script will prompt you to choose between:
- User-local installation (recommended)
- System-wide installation (requires sudo)
Requirements
Make sure Ollama is running before using qcmd:
ollama serve
Basic Usage
Using qcmd is as simple as typing your request in natural language:
qcmd "list all files in the current directory"
This will generate a command (like ls -la) and ask if you want to execute it.
Auto-Execute Mode
qcmd -e "find large log files"
Smart Auto-Fix Mode
qcmd -A "find Python files modified today"
The auto mode will automatically generate, execute, and fix commands without requiring confirmation. It will attempt to fix failed commands up to a maximum number of attempts.
Log Analysis Mode
qcmd --logs
Find and analyze log files on your system. The tool will detect available log files, let you select one, and provide AI-powered analysis of its content. It can also monitor logs in real-time with continuous analysis of new entries.
All Logs Mode
qcmd --all-logs
Displays a comprehensive list of all log files found on your system in a single view. Select any log file to analyze or monitor it in real-time.
Analyze Specific File
qcmd --analyze-file /path/to/file.log
Directly analyze a specific file using AI to identify patterns, errors, and issues.
Monitor File Continuously
qcmd --monitor /path/to/file.log
Continuously monitor a specific file in real-time, analyzing new content as it's added with AI.
Interactive Shell
qcmd -s
Start an interactive shell for continuous command generation.
Safety Features
qcmd prioritizes safety by ensuring you are always in control. It includes several safety features:
Always Confirms
Every command requires explicit confirmation before execution, except in auto mode.
Dangerous Command Detection
Detects potentially destructive commands and provides extra warnings.
Auto-Fix Confirmation
Asks for permission before attempting to fix failed commands (in normal mode).
Dangerous Command Detection
qcmd analyzes commands for dangerous patterns like:
- File system destructive operations (
rm -rf) - Disk formatting commands (
mkfs) - Raw device operations (
dd) - Fork bombs and other known dangerous patterns
When a potentially dangerous command is detected, you'll receive a clear warning and must explicitly type "yes" to proceed.
Safety Philosophy
AI-generated commands are powerful but should always be under human supervision. qcmd is designed to be helpful while ensuring you maintain complete control over what executes on your system.
Key Features
Auto Mode
Automatically generates, executes, and fixes commands until they succeed without requiring confirmation.
Use qcmd -A "your command"
Error Analysis
Analyzes errors and provides explanations and suggestions.
Use qcmd -a "your command"
Interactive Shell
Continuous operation with command history and tab completion.
Use qcmd -s
Command History
Saves and recalls previous commands.
Use qcmd --history
Tab Completion
Context-aware tab completion for arguments and commands.
Install with setup-qcmd.sh
Multiple Models
Switch between different AI models for best results.
Use qcmd -m model_name "command"
Log Analysis
Find, analyze, and continuously monitor system log files.
Use qcmd --logs or /logs in shell mode
File Monitoring
Analyze and continuously monitor any file with AI.
Use qcmd --monitor or /monitor in shell
Safety First
Always confirms before executing any command (except in auto mode), with special warnings for dangerous operations.
Commands in normal mode require explicit confirmation
Examples
Interactive Command Simulator
Try out qcmd commands with this interactive simulator:
Basic Command Generation
qcmd "list all files in the current directory"
qcmd "find large log files"
Auto-Execute Commands
qcmd -e "check disk space usage"
qcmd --execute "show current directory"
Using Different Models
qcmd -m llama2:7b "restart the nginx service"
qcmd --model deepseek-coder "create a backup of config files"
Adjusting Creativity
qcmd -t 0.7 "find all JPG images"
qcmd --temperature 0.9 "monitor network traffic"
AI Error Analysis
qcmd --analyze "find files larger than 1GB"
qcmd -a -m llama2:7b "create a tar archive of logs"
Auto Mode (Auto-Execute with Error Fixing)
qcmd --auto "find Python files modified today"
qcmd -A "search logs for errors"
qcmd -A -m llama2:7b "get system information"
Log Analysis
qcmd --logs
qcmd --logs -m llama2:7b
qcmd --all-logs
qcmd --analyze-file /var/log/syslog
qcmd --monitor /var/log/auth.log
Command-Line Options
Main Arguments
| Option | Description |
|---|---|
prompt |
Natural language description of the command you want |
Model Selection
| Option | Description |
|---|---|
--model, -m |
Model to use (default: qwen2.5-coder:0.5b) |
--list, -l |
List available models and exit |
--list-models |
Same as --list, shows available models |
Execution Options
| Option | Description |
|---|---|
--execute, -e |
Execute the generated command after confirmation |
--yes, -y |
Use simplified confirmation (just press Enter to execute) |
qcmd