Currently, aj is only available for the Fish shell, but you are more than welcome to add support for your preferred shell!
aj is a simple shell tool that automatically fixes mistakes in your last command. If you mistype a command, just type aj, and it will suggest a correction based on what you likely meant to run.
Did you know that "aj" means "ouch" in Swedish? That's why this tool is named aj — to help ease the pain of mistyped commands! Plus, aj is quite similar to ai, which powers the tool to correct your commands.
- Automatically detects and fixes common typos in shell commands
- Suggests a corrected command and prompts before execution
- Simple and lightweight, built with Go
-
Install Go (version 1.23):
Follow the instructions on the official Go website to install Go version 1.23.
-
Clone the repository:
git clone https://github.com/Carlltz/aj cd aj -
Create a
.envfile based on.env.exampleand add your OpenAI API key:cp .env.example .env
Then, edit the
.envfile to include your OpenAI API key:OPENAI_API_KEY=your-api-key-here
-
Build the project:
make build
-
Move the binary to a directory in your
$PATH(optional but recommended):sudo mv aj /usr/local/bin/
Simply type aj after running a command that failed:
$ eco Hello, World!
$ aj
Last command: eco Hello, World!
Ctrl+C to exit or Enter to run: echo Hello, World!Press Enter to run the suggested command or Ctrl+C to cancel.
The usage of the OpenAI API is very affordable. Approximately every 15-25 corrected commands cost about 0.001 USD, making it a cost-effective solution for fixing command-line mistakes.
The .env file must contain a valid OpenAI API key to function properly. You can obtain an API key from OpenAI.
I'm not very familiar with Go, so I might not have followed "best practices" at all. If you have suggestions for improvement, feel free to contribute!
MIT License
Pull requests are welcome! Feel free to open an issue if you encounter any bugs or have feature suggestions.