Skip to content

motionharvest/AskGPT-Terminal-Command-Assistant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

AskGPT Terminal Command Assistant

AskGPT is a lightweight Bash script that turns your terminal into an AI-powered command-line assistant. Type natural language like:

ask "show all listening ports"

…and get the exact shell command back—copied straight to your clipboard.


✨ Features

  • 🗣 Natural Language Queries Ask for a terminal command in plain English. No syntax memorization required.

  • 📋 Clipboard Copy The result is automatically copied to your clipboard via xclip.

  • 🧠 Context-Aware Memory Remembers the last 10 questions and responses and includes them in the prompt for improved relevance.

  • 🛠 Automatic Setup Installs xclip if missing. Just drop in and go.

  • ⚡ Fast & Local Just Bash + curl + jq. No extra dependencies or daemons.


🚀 Installation

  1. Save the Script Run this one-liner in your terminal:

     mkdir -p ~/.local/bin && curl -o ~/.local/bin/askgpt.sh https://raw.githubusercontent.com/motionharvest/AskGPT-Terminal-Command-Assistant/main/askgpt.sh && chmod +x ~/.local/bin/askgpt.sh
  2. Create an Alias Add this to your ~/.bashrc or ~/.zshrc:

    alias ask='~/.local/bin/askgpt.sh'

    Then reload your shell:

    source ~/.bashrc   # or source ~/.zshrc

🧪 Usage

Just type:

ask "find large files in this directory"

And you’ll get:

find . -type f -exec du -h {} + | sort -rh | head -n 10

The command is printed to the terminal and automatically copied to your clipboard.


📁 Memory File

AskGPT creates and maintains a memory file at:

~/.local/bin/askgpt.memory

It stores the last 10 question-response pairs and reuses them as context for better continuity.


🔐 API Key

This script uses the OpenAI API. You’ll need a valid sk- or gpt-4o project key. Add it inside the script like this:

API_KEY="your_openai_key_here"

💡 Tip

The more you use it, the smarter your session becomes—without ever storing data online. It's just shell + memory.


📜 License

MIT License. Use it, modify it, share it. Just don’t paste your API key in a public repo.

About

This repository contains a script, askgpt.sh, that allows users to query OpenAI's GPT-4 model for terminal commands using natural language. The script not only provides the appropriate command but also copies it to your clipboard for convenience.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages