Skip to content

An advanced Bash shell functioning as an AI-powered terminal assistant with Prompt HISTORY functionality.

License

Notifications You must be signed in to change notification settings

NeverBeLazyG/bash-ai-plus

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bash AI Plus

Bash AI Plus (baip) is an advanced Bash shell script functioning as an AI-powered terminal assistant, with Prompt HISTORY functionality.

Just press arrow keys to view your Prompt history like you would use in in a normal CLI.

examples:

image

image

Leveraging the newest OpenAI's capabilities (standard model used: gpt-4o-mini, can be changed in config file), it allows you to ask questions and perform terminal-based tasks using natural language (English, German etc.). It provides answers and command suggestions based on your input and allows you to execute or edit the suggested commands if desired.

Bash AI is not only powerful out of the box, but also expandable!
With its plugin architecture, you can easily add your own tools, thereby empowering Bash AI to accomplish even more, and extending its functionality beyond its original capabilities.

Features

Bash AI offers the following features:

  • 100% Shell Script
    No need to install anything. Just run it!

  • Plugins!
    Extend Bash AI's functionality by adding plugins known as "tools".

  • Natural Language Interface
    Communicate with the terminal using everyday language.

  • Question Answering
    Get answers to all your terminal questions by ending your request with a question mark.

  • Command Suggestions
    Receive intelligent command suggestions based on your input.

  • Command Information
    Get detailed information about the suggested commands.

  • Distribution Awareness
    Get answers and commands that are compatible with, and related to, your specific Linux distribution.

  • Command Execution
    Choose to execute the suggested commands directly from Bash AI.

  • Command Editing
    Edit the suggested commands before execution.

  • Error Examination
    Examine the error messages generated by the suggested commands and attempt to fix them.

  • Persistent Memory
    Remembers your previous requests and uses them to improve future suggestions.

  • Directory Awareness
    Automatically detects and uses the current directory when executing commands.

  • Locale Awareness
    Automatically detects your system's locale and uses it to provide localized responses.

  • Vim Awareness
    Automatically detects if you are using Vim and provides Vim-specific suggestions.

  • HISTORY like in a CLI
    The history function is what it makes it different to the Original script by Hezkore/bash-ai.

Setup

  1. To setup Bash AI quickly, you can run the following command:
curl -sS https://github.com/NeverBeLazyG/bash-ai-plus/main/install.sh | bash

Be sure to have curl and jq installed before running.

sudo apt install jq

Warning

Never run unknown scripts without reviewing them for safety. Read the install script here.

  1. Run baip to start Bash AI Plus.
Manual Setup
  1. Clone or download the repository:

    git clone https://github.com/NeverBeLazyG/bash-ai-plus
  2. Make the script executable:

    chmod +x baip.sh
  3. Execute Bash AI:

    ./baip.sh
  • (Optional) For convenience, you can create a shortcut to the baip.sh script. There are two ways to do this:

    • Create a symbolic link in /usr/local/bin. This will allow you to run the script from anywhere, without having to type the full path. Replace path/to/baip.sh with the actual path to the baip.sh script:

       ln -s path/to/baip.sh /usr/local/bin/baip
    • Alternatively, you can create an alias for the baip.sh script in your .bashrc file. This will also allow you to execute the script using the baip command, reducing the need for typing the full path to the script each time. Replace path/to/baip.sh with the actual path to the baip.sh script:

       alias baip='path/to/baip.sh'
      

Configuration

On the first run, a configuration file named baip.cfg will be created in your ~/.config directory.

Important

Always remove baip.cfg before updating Bash AI to avoid compatibility issues.

You must provide a OpenAI API key in the key= field of this file. The OpenAI API key can be obtained from your OpenAI account.

Caution

Keeping the key in a plain text file is dangerous, and it is your responsibility to keep it secure.

You can also change the GPT model (the default model is set to gpt-4o-mini), temperature and many other things in this file.

Usage

Bash AI Plus operates in two modes: Interactive Mode and Command Mode.

To enter Interactive Mode, you simply run baip without any request. This allows you to continuously interact with Bash AI without needing to re-run the command.

In Command Mode, you run baip followed by your request, like so: baip your request here

Example usage:

baip create a new directory with a name of your choice, then create a text file inside it

You can also ask questions by ending your request with a question mark:

baip what is the current time?

Plugins and tools

Plugins are OpenAI tools that expand Bash AI's functionality, but they are not included in the default Bash AI setup.
All tools should be placed in your ~/.baip_tools directory.
You can see which tools are currently installed by running baip, and Bash AI will list them for you.

Tools are nothing more than a shell script with a init and execute function.
You can find examples and available tools in the tools folder.
Feel free to move them to your ~/.baip_tools directory to enable them!

History function like in a CLI

The history function is what it makes it different to the Original script by Hezkore/bash-ai.

Known Issues

  • In Command Mode, avoid using single quotes in your requests.
    For instance, the command baip what's the current time? will not work. However, both baip "what's the current time?" and baip what is the current time? will execute successfully.
    Please note that this issue is specific to the terminal, and does not occur in Interactive Mode.

Prerequisites

About

An advanced Bash shell functioning as an AI-powered terminal assistant with Prompt HISTORY functionality.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%