Skip to main content

original work

https://github.com/0xacx/chatGPT-shell-cli

I translated it to python, and added some features, Few things was not working for me, also updated to gpt 4o-mini
** greate work from the original authour **

GPT-shell-4o-mini

A simple, lightweight Python CLI to use OpenAI's ChatGPT and DALL-E from the terminal.

Features ✨

🌍 Cross-Platform Support

  • Windows 10/11 - Full support with automatic environment variable setup
  • macOS - Works seamlessly on all versions
  • Linux - Supports all major distributions (Ubuntu, Fedora, Debian, Arch, etc.)

🧠 Smart Terminal Context

  • User Profile - Remembers your OS, username, and distribution
  • Terminal Session Info - Sends current working directory, shell type, and environment to ChatGPT
  • Intelligent Responses - ChatGPT sees your context and environment for better assistance

🚀 Easy Setup

  • First-run wizard - Automatic API key setup and verification
  • Python Package - Installable via pip for easy management
  • Cross-platform - Works on Windows, macOS, and Linux

Getting Started

Prerequisites

  • Python 3.7+ (usually pre-installed)
  • An OpenAI API key - Get one free at OpenAI

Installation

Installation

Pip Installation (Recommended for all platforms):

pip install gpt-shell-4o-mini

After installation, run gpt to start the setup wizard:

gpt

The wizard will:

  • Prompt for your OpenAI API key
  • Verify the key with OpenAI
  • Save it securely in your os environment
  • Create your user profile
  • Files Will be created at your home directory as chatgpt_py**

Uninstallation

IMPORTANT: Command Order Matters

Always run gpt-remove BEFORE pip uninstall - the gpt-remove command is part of the package and will be removed by pip uninstall.


gpt-remove

What gpt-remove does:

  • Interactive confirmation - asks before proceeding
  • Removes configuration files - deletes ~/.chatgpt_py_* files
  • Cleans environment variables - removes OPENAI_KEY from shell profiles
  • Uninstalls Python package - runs pip uninstall gpt-shell-4o-mini automatically
  • Shows progress - detailed feedback throughout the process

Result: Complete removal of all traces of the package


Method 2: Basic Package Removal

pip uninstall gpt-shell-4o-mini

What pip uninstall does:

  • Removes Python package - deletes package from site-packages
  • Removes commands - deletes gpt, chatgpt, and gpt-remove commands
  • Leaves configuration files - ~/.chatgpt_py_* files remain
  • Leaves environment variables - OPENAI_KEY in shell profiles remains

Result: Package removed but manual cleanup required


Method 3: Manual Cleanup After Basic Uninstall

If you already ran pip uninstall and need to clean up:

# Download and run the uninstall module
curl -O https://raw.githubusercontent.com/wkdkavishka/GPT-shell-4o-mini/main/chatgpt/uninstall.py
python uninstall.py

What this does:

  • Removes configuration files - cleans up ~/.chatgpt_py_* files
  • Cleans environment variables - removes OPENAI_KEY from shell profiles
  • Cannot uninstall package - package already removed

Result: Configuration cleanup only


Manual Cleanup Required After pip uninstall

If you used pip uninstall without gpt-remove, manually remove:

  • Chat history: ~/.chatgpt_py_history
  • Custom system prompt: ~/.chatgpt_py_sys_prompt
  • User profile: ~/.chatgpt_py_info
  • Environment variables: OPENAI_KEY from shell profiles (~/.bashrc, ~/.zshrc, etc.)

Usage

Command Line Options

gpt [OPTIONS]

Basic Options

  • -h, --help - Show help message and exit
  • -p, --prompt PROMPT - Provide prompt directly instead of starting chat
  • --prompt-from-file FILE - Provide prompt from a file
  • -l, --list - List available OpenAI models

Model & Response Options

  • -m, --model MODEL - Model to use (default: gpt-4o-mini)
  • -t, --temperature TEMPERATURE - Sampling temperature (default: 0.7)
  • --max-tokens MAX_TOKENS - Max tokens for completion (default: 1024)
  • -s, --size SIZE - Image size for DALL-E (default: 512x512)

System Prompt Management

  • -i, --init-prompt PROMPT - Provide initial system prompt (overrides default)
  • --init-prompt-from-file FILE - Provide initial system prompt from file
  • --sys-prompt PROMPT - Set or update custom system prompt (saved to ~/.chatgpt_py_sys_prompt)
  • --get-sys-prompt - Show current custom system prompt
  • --reset-sys-prompt - Remove custom system prompt and use default

Debug Options

  • --debug - Print debug information including context sent to AI

Usage Examples

Interactive Chat Mode

gpt
# Starts interactive chat with ChatGPT

Single Prompt Mode

gpt -p "What is the regex to match an email address?"
gpt --prompt "Translate to French: Hello World!"

Pipe Mode

echo "What is the command to get all pdf files created yesterday?" | gpt
ls -la | gpt -p "Explain these file permissions"

File Input

gpt --prompt-from-file my_prompt.txt
gpt --init-prompt-from-file custom_system_prompt.txt

Model Configuration

gpt --model gpt-4 --temperature 0.9 --max-tokens 2000
gpt -m gpt-4o -t 0.5

System Prompt Management

# Set custom system prompt
gpt --sys-prompt "You are a helpful Python programmer. Always provide code examples."

# View current system prompt
gpt --get-sys-prompt

# Reset to default
gpt --reset-sys-prompt

# Use temporary system prompt
gpt -i "You are a chef. Provide cooking advice." -p "How do I make pasta?"

Debug Mode

gpt --debug -p "Why is my script not working?"
gpt --debug  # Starts interactive chat with debug info

🧠 Terminal Context Feature

How It Works

GPT-shell-4o-mini automatically sends contextual information with every prompt:

User Profile (~/.chatgpt_py_info):

  • Your username
  • Operating system and version
  • Linux distribution (if applicable)

Terminal Session (captured in real-time):

  • Current working directory
  • Shell type (bash, zsh, PowerShell, etc.)
  • Environment information

Example

When you run gpt, ChatGPT sees:

[Static Profile: User: john | OS: Linux | Distro: Ubuntu 22.04]
[Terminal Session (Shell: bash | CWD: /home/john/project):
]

You: How do I fix this Python error?

ChatGPT response will be context-aware:

"I see you're working in the /home/john/project directory on Ubuntu..."

Debug Mode

Use --debug to see exactly what context is sent to ChatGPT:

gpt --debug -p "Help me debug this issue"

This will show:

  • The full user profile
  • Terminal session information
  • Complete message history being sent
  • Model parameters being used

Support

For issues, questions, or contributions, please visit the
GitHub Repository

Interactive Commands

During interactive chat mode, you can use these special commands:

  • image: Generate images - Start a prompt with image: followed by description
    • Example: image: a cute cat sitting on a laptop
  • history View your chat history
  • models List available OpenAI models
  • model: Get details on a specific model - Start with model: followed by model ID
    • Example: model: gpt-4o-mini
  • command: Generate and execute commands - Start with command: followed by description
    • Example: command: list all files larger than 100MB in current directory
  • exit, quit, q Exit the chat

Image Generation

# In interactive mode
image: a beautiful sunset over mountains

# With specific size
gpt -s "1024x1024" -p "image: futuristic cityscape"

Available image sizes: 256x256, 512x512, 1024x1024, 1792x1024, 1024x1792, 2048x2048, 4096x4096

Command Generation

# In interactive mode
command: find all Python files with syntax errors

# As single prompt
gpt -p "command: compress all log files older than 30 days"

⚠️ Safety Warning: Generated commands are checked for dangerous patterns. You'll be asked to confirm before execution.

Metadata

Release files for gpt-shell-4o-mini 1.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gpt-shell-4o-mini 1.2.2
File Size Uploaded Provenance
gpt_shell_4o_mini-1.2.2.tar.gz 23.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for gpt-shell-4o-mini 1.2.2
File Interpreter ABI Platform
gpt_shell_4o_mini-1.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 45.8 kB

Release files / gpt_shell_4o_mini-1.2.2.tar.gz

Download URL gpt_shell_4o_mini-1.2.2.tar.gz
Size 23.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e463085130562be60d1a6de4c03b17a68ea430a69623b8169d3371d4bc3a8fc2
BLAKE2b-256 checksum
How to use checksums
b95f9301607c2bc0ae1f2a530c3b017eba26134804bd4e15deb089ad74446f3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / gpt_shell_4o_mini-1.2.2-py3-none-any.whl

Download URL gpt_shell_4o_mini-1.2.2-py3-none-any.whl
Size 22.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
da847375e2c2d4c1369104ff2618010654c71ba0ffcdc22c69dcebca646777a1
BLAKE2b-256 checksum
How to use checksums
e42101ffeab4abadb5a6ced0fe52df146050d46758a0f188bc0db2f55d3effb3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Security for gpt-shell-4o-mini 1.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page