AI Shell: Transforming Natural Language into Shell Commands

Mar 8, 2024 | Educational

![AI Shell logo](https://cdn.builder.io/api/v1/image/assets/YJIGb4i01jvw0SRdL5Bt/b5b9997cec2c4fffb3e5c5e9bb4fed7d)

A CLI that converts natural language to shell commands.

![Current version](https://img.shields.io/npm/v/@builder.io/ai-shell)

Gif Demo

Inspired by the GitHub Copilot X CLI, but open source for everyone.

Getting Started with AI Shell

AI Shell helps you convert natural language prompts directly into shell commands, making it an essential tool for developers and tech enthusiasts. Here’s a step-by-step guide to set it up:

Setup

  1. The minimum supported version of Node.js is v14.1. Install AI Shell using:
  2. npm install -g @builder.io/ai-shell
  3. Retrieve your API key from OpenAI. Note that you will need to create an account and set up billing if you haven’t done that yet.
  4. Set the key so AI Shell can use it:
  5. ai config set OPENAI_KEY=your_token

    This will create a .ai-shell file in your home directory.

Usage

Now that you have everything set up, you can start using your AI Shell. Here’s how:

ai prompt

For example:

ai list all log files

You will receive an output suggesting a command:

Your script: find . -name "*.log"

Explanation:

  • This command searches for all files with the extension .log in the current directory and any subdirectories.

From here, you can choose to run the suggested command, revise it, or cancel.

Special Characters

When using certain special characters like ? or *, you may encounter strange behaviors. If this happens, you can wrap your prompt in quotes:

ai "what is my ip address"

Chat Mode

You can engage in a conversational manner with the AI by entering:

ai chat

This allows for a more interactive experience, helping you receive responses in natural language directly from the CLI.

Silence Mode

To skip the explanations, use:

ai -s list all log files

Alternatively, set this option as a preference:

ai config set SILENT_MODE=true

Custom API Endpoint

You can set a custom OpenAI API endpoint:

ai config set OPENAI_API_ENDPOINT=your_proxy_endpoint

Set Language

The default language is English. To switch, use the corresponding language keys. For instance, to switch to Simplified Chinese:

ai config set LANGUAGE=zh-Hans

Upgrading

Check your installed version:

ai --version

If it’s not the latest version, run:

npm update -g @builder.io/ai-shell

Or simply use the AI Shell:

ai update

Troubleshooting Common Issues

429 Error

If you encounter a 429 error from OpenAI, it may be due to incorrect billing setup or excessive quota usage. Follow the guide here to resolve this issue. You can activate billing at this link, ensuring that a payment method is added if you are not under an active grant from OpenAI.

For more insights, updates, or to collaborate on AI development projects, stay connected with **fxis.ai**.

Conclusion

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

For those who wish to contribute or find help regarding AI Shell, check out the issues page or the Contribution Guide for setup instructions.

Final Notes

Have fun exploring the features of AI Shell—it’s designed to make your command line experience more efficient and intuitive!

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox