A CLI that converts natural language to shell commands.
Inspired by the GitHub Copilot X CLI, but open source for everyone.
AI Shell
Ruby port by Antonio Molinari, inspired by the original BuilderIO/ai-shell CLI.
Setup
Requires Ruby 3.0+
-
Install ai shell:
gem install ai-shellOr from this repository:
bundle install bundle exec rake install # or gem build ai-shell.gemspec && gem install ./ai-shell-*.gem -
Retrieve your API key from OpenAI
Note: If you haven't already, you'll have to create an account and set up billing.
-
Set the key so ai-shell can use it:
ai config set OPENAI_KEY=<your token>This will create a
.ai-shellfile in your home directory.
Usage
ai <prompt>
For example:
ai list all log files
Then you will get an output where you can choose to run the suggested command, revise it via a prompt, edit it, copy it, or cancel.
Special characters
Some shells handle characters like ? or * specially. Wrap the prompt in quotes if needed:
ai 'what is my ip address'
Chat mode
ai chat
Engage in a conversation with the AI directly through the CLI.
Silent mode (skip explanations)
ai -s list all log files
Or save the preference:
ai config set SILENT_MODE=true
Custom API endpoint
ai config set OPENAI_API_ENDPOINT=<your proxy endpoint>
Default: https://api.openai.com/v1
Set Language
| Language | Key |
|---|---|
| English | en |
| Simplified Chinese | zh-Hans |
| Traditional Chinese | zh-Hant |
| Spanish | es |
| Japanese | jp |
| Korean | ko |
| French | fr |
| German | de |
| Russian | ru |
| Ukrainian | uk |
| Vietnamese | vi |
| Arabic | ar |
| Portuguese | pt |
| Turkish | tr |
| Indonesian | id |
| Italian | it |
ai config set LANGUAGE=zh-Hans
Config UI
ai config
Upgrading
ai --version
gem update ai-shell
Or:
ai update
Development
bundle install
bundle exec bin/ai --help
bundle exec bin/ai config set OPENAI_KEY=<your token>
bundle exec bin/ai list all log files
Common Issues
429 error
This is due to incorrect billing setup or excessive quota usage. Please follow this guide to fix it.
You can activate billing at this link.
Motivation
I am not a bash wizard, and am dying for access to the copilot CLI, and got impatient.
Credit
- Ruby port by Antonio Molinari
- Inspired by BuilderIO/ai-shell
- Thanks to GitHub Copilot for their amazing tools and the idea for this
- Thanks to Hassan and his work on aicommits, which inspired the workflow and some parts of the code and flows
- Original Node.js implementation by Builder.io