cmd-ai is a natural language shell assistant powered by AI. It turns plain English (or any prompt) into real, executable shell commands — with safety, explanation, history, and autocompletion built-in.
To install cmd-ai, use the following command:
npm install -g cmd-aiEnsure you have Node.js installed on your system before proceeding with the installation.
Before using the assistant, set your OpenAI API key:
ai configYour key is securely stored in:
~/.ai-config.jsonOnce installed, you can invoke this library using the ai command. For example:
ai Tell me how much free space is left on the diskThis will first display the suggested command based on your input. If you confirm by pressing "Enter," the command will then be executed.
Here some pre-defined commands:
ai [your task here] [--flags]
ai list all running Docker containers
ai remove all .DS_Store files recursively
ai config # Set your OpenAI API key
ai history # View past commands
ai man # Show help
ai install-autocomplete # Automatically set up autocomplete--explain– Ask AI to explain the command before returning it.--dry– Show the command but don’t execute it.--helpor-h– Show help screen.
Generate and install the autocompletion script:
ai install-autocompleteThis will:
- Generate the autocomplete script at
~/.cmd-ai-completion.sh - Add source
~/.cmd-ai-completion.shto your.bashrcor.zshrc
cmd-ai is designed with safety in mind. It includes mechanisms to filter harmful or inappropriate content. However, always review AI-generated outputs before using them in critical applications.
All AI-generated commands are saved (with timestamp and status) in:
~/.ai-command-history.jsonView them using:
ai historyThis project is licensed under the MIT License.
Made by Broda Noel (brodanoel@gmail.com)
The use of cmd-ai is entirely at your own risk.
This tool uses artificial intelligence to generate shell commands automatically. While it includes safety checks to prevent destructive operations, it does not guarantee the accuracy, safety, or appropriateness of any generated command.
You are solely responsible for reviewing and understanding every command before executing it.
The author(s) of this project accept no liability for data loss, system damage, security breaches, or any unintended consequences resulting from the use of this software.
