Powering your terminal with AI

Do you wanna try your terminal powered by AI, here I will show you how to it is easy and useful!

Powering your terminal with AI
Photo by Possessed Photography / Unsplash

TL;DR

AI is becoming a rule tool nowadays, in this post I will show you how to power your terminal with ChatGPT AI.

Prerequisites

  • A ChatGPT API account where you will generate an API-key.
  • Curl package to download the installation script
  • JQ package required by the bash script to interact with ChatGPT response

Get a ChatGPT API token 🉐

Go to ChatGPT web site and open a new account at OpenAI, get a new API token, it is free as OpenAI will charge you credits to use their API 5 usd, after that you could top up your account dont worry it is really cheap like 0.001 per request so if you top up 5 usd, that will be enough for you.

Install ChatGPT cli 🤖

You will need to install the script https://github.com/0xacx/chatGPT-shell-cli which will allow you interact with ChatGPT, so run this in your terminal:

curl -sS https://raw.githubusercontent.com/0xacx/chatGPT-shell-cli/main/install.sh | sudo -E bash

Arch users could use Aur 🛺

if you're an Arch user as me you could use Aur, for instance by using paru

paru -S chatgpt-shell-cli

But if you're as me and doesn't like any Aur wrapper just clone it and install it:

# all my Aur packages are in Aur folder
cd Aur
git clone https://aur.archlinux.org/chatgpt-shell-cli.git
cd chatgpt-shell-cli
makepkg -si

Final step add your API Key 🧸

You should now export a variable OPENAI_KEY in your shell, you could do it in your .bashrc by adding

export OPENAI_KEY=<paste-your-openai-key-here>

restart your shell and you're ready to go with your AI at your terminal:

demo of ChatGPT at my terminal

Sources