Skip to content

Latest commit

 

History

History
68 lines (43 loc) · 2.03 KB

README.md

File metadata and controls

68 lines (43 loc) · 2.03 KB

aihelp

A convenience tool for getting help from AI on the command line.

It uses the OpenAI API to get suggestions for the last command you ran.

Installation

Automatic (Ubuntu, Debian only)

Note that this is deemed unsafe. Don't do this if you don't trust the author.

wget -O - https://raw.githubusercontent.com/v-spassky/aihelp/main/distribution/install.sh \
| bash /dev/stdin folder-to-save-script-to shell-conf-file command-name
  • folder-to-save-script-to - the script will be downloaded to this path. Make sure it is in your $PATH;
  • shell-conf-file - the script will add an alias to this file;
  • command-name - the name of the command that will be used to run the script.

Example:

wget -O - https://raw.githubusercontent.com/v-spassky/aihelp/main/distribution/install.sh \
| bash /dev/stdin ~/.local/bin/ ~/.zshrc aihelp

Afterwards, rerun your shell configuration file (e.g. source ~/.zshrc).

Manual
  • Download the script to a folder that is in your $PATH (i.e. at ~/.local/bin);
  • Make it executable;
  • Add an alias to your ~/.bashrc, ~/.zshrc or whatever:

alias aihelp="aihelp.sh \"\$(history | cut -c 8- | tail -n 1)\""

  • Make sure you have jq installed.

Configuring

Open the script with a text editor of your choice and set the OPENAI_API_TOKEN variable:

nano ~/.local/bin/aihelp.sh

...

OPENAI_MODEL="gpt-3.5-turbo"
OPENAI_API_TOKEN="sk-zWHHjthO...LudGVG"
PROMPT_PREFIX="What is wrong with this command: "
PROMPT_POSTFIX=" ? I ran it in Linux terminal and it gave me an error. \
Please give a concise answer (ideally, 3-4 sentences)."

...

You might as well change all the other settings to your liking.

Also, you can change the alias to something else if you wish:

alias whatever="aihelp.sh \"\$(history | cut -c 8- | tail -n 1)\""

Usage

Print aihelp to get a suggestion on the last command you ran.