Skip to content

GPT Terminal is your AI-assistant on the command line.

Notifications You must be signed in to change notification settings

franzos/gpt-terminal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GPT Terminal

GPT Terminal is your AI-assistant on the command line. Whenever a command fails, simply type gpt-help to get a suggestion on how to fix it.

This application has been developed on, and tested with bash, but should work on any modern shell.

  • Relies on GPT 3.5
  • Right now Linux only (due to notify-send)
  • Should work with any modern shell

GPT Terminal

Installation

Install with pip:

pip3 install gpt-terminal

Make sure notify-send is available on your system. On Guix, you can install it with:

guix package -i libnotify

Set OpenAI API key (GPT 3.5):

export OPENAI_API_KEY='sk-...'

Usage

Make sure gpt-terminal is running:

You can run GPT Terminal in a seperate terminal window, or as a service with systemd or shepherd.

gpt-terminal

Activate suggestions for current terminal:

exec &> >(tee -a /home/$(whoami)/.gpt_terminal.log)

To restore the original behaviour, open a new terminal or run:

exec &> /dev/tty

To get help on the last command, simply type:

echo gpt-help

Alias

You can setup a alias in your .bashrc:

alias gpt-help='echo gpt-help'

Then simply type:

gpt-help

Development

The approach here is fairly simple:

  1. Redirect all shell in-, and output to a log file.
  2. Have gpt-terminal tail the log file.
  3. Whenever you type gpt-help, gpt-terminal will send the last command to ChatGPT
  4. Once we got the response, a desktop notification is triggered with notify-send

Setup

git clone https://github.com/franzos/gpt-terminal; cd gpt-terminal
python3 -m venv venv
source venv/bin/activate
pip3 install .

TODO

This was just thrown together out of curiosity. There is a lot of room for improvement.

  • Tweak desktop notification
  • Improve OS recognition (to provide better suggestions)
  • Support other LLM's (local and API)
  • Store log in ~/.local/share/gpt-terminal/ or /tmp/... instead
  • Supply API key via config or command line
  • A more obvious name
  • ...

About

GPT Terminal is your AI-assistant on the command line.

Topics

Resources

Stars

Watchers

Forks

Languages