reTermAI

July 6, 2025 ยท View on GitHub

 ___   ___   _____   ___   ___   __ __    __    _
| _ \ | __| |_   _| | __| | _ \ |  V  |  /  \  | |
| v / | _|    | |   | _|  | v / | \_/ | | /\ | | |
|_|_\ |___|   |_|   |___| |_|_\ |_| |_| |_||_| |_|

[reTermAI] Smart command assistant for your terminal ๐Ÿง ๐Ÿ’ป

Buy Me a Coffee


๐Ÿ“„ Project Website

Looking for a better overview or prettier version of this README?
๐Ÿ‘‰ Check out the reTermAI landing page:
https://pie0902.github.io/reterm-site


Image

reTermAI

๐Ÿ’ก A terminal command recommender powered by AI and your own shell history.

Demo GIF

demo

โœจ Features

  • ๐Ÿ” Recommends relevant terminal commands based on your past history using OpenAI or Gemini
  • ๐Ÿง  Supports intelligent matching by keyword or partial input
  • โšก Easy to install via pip
  • ๐Ÿš Supports zsh and bash shell history
  • ๐Ÿ” API keys managed via .env

๐Ÿ“ฆ Installation

pip install reterm-ai

Or, for local development:

git clone https://github.com/pie0902/reTermAI.git
cd reTermAI
pip install -e .

โš™๏ธ Usage

๐Ÿ”ฎ AI-powered command suggestions:

reterm suggest

Options:

OptionDescription
--history-limit, -hlNumber of recent commands to read (default: 300)
--context-limit, -clHow many commands to feed into the LLM (default: 20)
--provider, -pLLM to use (openai or gemini)

Examples:

reterm suggest -p gemini

reterm suggest --history-limit 500 --context-limit 30
# Basic suggestion
reterm suggest

# Suggest using Gemini and 50 recent commands
reterm suggest -hl 50 -p gemini

# Suggest using OpenAI and 30 context commands
reterm suggest --provider openai --context-limit 30

# Search for past docker commands
reterm match docker

# Show up to 10 matching commands
reterm match docker -l 10


๐Ÿ”Ž Match past commands by keyword:

reterm match docker

Options:

OptionDescription
--limit, -lMax number of matching results to show (default: 5)

๐Ÿ” Configuration

Add a .env file in your home or project directory:

OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxx
GOOGLE_API_KEY=your-gemini-api-key
KeyUsed for
OPENAI_API_KEYRequired if using --provider openai
GOOGLE_API_KEYRequired if using --provider gemini

You can also refer to the included .env.example.


๐Ÿ“‚ Project Structure

reterm/
โ”œโ”€โ”€ cli.py          # Main CLI interface
โ”œโ”€โ”€ llm.py          # LLM integration (OpenAI, Gemini)
โ”œโ”€โ”€ shell.py        # Shell history detection and parsing
โ”œโ”€โ”€ config.py       # API key loader
โ”œโ”€โ”€ welcome.py      # ASCII and help panel

๐Ÿง‘โ€๐Ÿ’ป Contributing

We welcome contributions! Fork the repo, create a feature branch, and open a pull request.

git checkout -b feat/your-feature

Optional ideas:

  • Add support for fish shell
  • Add model options (e.g. gpt-4o, gemini-pro)
  • Improve LLM prompt formatting

๐Ÿ“„ License

Apache License 2.0