A simple, lightweight CLI to use OpenAI's ChatGPT and DALL-E from the terminal
Project description
original work
https://github.com/0xacx/chatGPT-shell-cli
GPT-shell-4o-mini
A simple, lightweight CLI to use OpenAI's ChatGPT and DALL-E from the terminal.
This project now uses a Python installer (install.py) for setup and a Python uninstaller (remove.py) for clean removal.
The main shell script is chatgpt.sh, which is installed to your system path for easy access.
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.)
🧠 Advanced Terminal Context
- Static User Profile - Remembers your OS, username, and distribution
- Dynamic Session Capture - Sends recent terminal commands AND outputs to ChatGPT
- tmux support - Captures last 30 lines automatically
- screen support - GNU screen buffer capture
- History fallback - Works even without tmux/screen
- Intelligent Responses - ChatGPT sees your errors, current directory, and shell type
🚀 Seamless Setup
- First-run wizard - Automatic API key setup and verification
- No external dependencies - Uses Python's requests library (no curl needed)
- Platform-aware - Automatically configures for your OS
Getting Started
Prerequisites
- Python 3.7+ (usually pre-installed)
- An OpenAI API key - Get one free at OpenAI
Optional (for best terminal context):
- tmux - Highly recommended for full terminal session capture
sudo apt install tmux # Ubuntu/Debian sudo dnf install tmux # Fedora brew install tmux # macOS
Installation
Windows
Pip Installation (Only method for Windows):
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 to Windows environment variables automatically
- Create your user profile
Note: Manual installation via
install.pyis not supported on Windows.
macOS / Linux
Option 1: Pip Installation (Recommended)
pip install gpt-shell-4o-mini
Run gpt to start the setup wizard.
Option 2: Manual Installation
Quick install without cloning:
curl -O https://raw.githubusercontent.com/wkdkavishka/GPT-shell-4o-mini/origin/install.py
sudo python3 install.py
Or clone and install:
git clone https://github.com/wkdkavishka/GPT-shell-4o-mini.git
cd GPT-shell-4o-mini
sudo python3 install.py
You will be prompted for your OpenAI API key during the installation. Alternatively, you can provide your key directly:
sudo python3 install.py --key <YOUR_OPENAI_API_KEY>
This will:
- Download and install
chatgpt.shto/usr/local/bin/gpt - Optionally create a symlink
/usr/local/bin/chatgpt - Add your API key and
/usr/local/binto your shell profile
Uninstallation
The remove.py script provides comprehensive uninstallation that works whether you installed via pip or manually.
For a quick uninstall without cloning:
curl -O https://raw.githubusercontent.com/wkdkavishka/GPT-shell-4o-mini/origin/remove.py
python3 remove.py
# Or with sudo if you used manual installation:
sudo python3 remove.py
What it removes:
- Package installed via pip (if applicable)
- Manual installation from
/usr/local/bin/gptand/usr/local/bin/chatgpt(if applicable) OPENAI_KEYand/usr/local/binPATH modifications from your shell profiles- Chat history file (
~/.chatgpt_py_history)
The script automatically detects how the package was installed and removes it accordingly.
Manual Installation
If you want to install manually:
- Download the
chatgpt.shfile to a directory in your$PATH - Add your OpenAI API key to your shell profile:
export OPENAI_KEY=your_key_here - Make sure
/usr/local/binis in your$PATH - (Optional) Install imgcat for iTerm2 image support
Usage
Start
Chat Mode
- Run the script by using the
gptorchatgptcommand anywhere. By default the script uses thegpt-4o-minimodel.
Pipe Mode
- You can also use it in pipe mode:
echo "What is the command to get all pdf files created yesterday?" | gpt
Script Parameters
- You can also pass the prompt as a command line argument:
gpt -p "What is the regex to match an email address?"
🧠 Terminal Context Feature
How It Works
GPT-shell-4o-mini automatically sends contextual information with every prompt:
Static Profile (~/.chatgpt_py_info):
- Your username
- Operating system and version
- Linux distribution (if applicable)
Dynamic Terminal Session (captured in real-time):
- Current working directory
- Shell type (bash, zsh, PowerShell, etc.)
- Recent terminal commands AND their outputs!
Example
When you run gpt in tmux, ChatGPT sees:
[Static Profile: User: john | OS: Linux | Distro: Ubuntu 22.04]
[Terminal Session (Shell: bash | CWD: /home/john/project | Source: tmux):
john@ubuntu:~/project$ npm run dev
Error: Missing script: "dev"
]
You: How do I fix this?
ChatGPT response will be context-aware:
"I see you're missing the 'dev' script in package.json. Since you're on Ubuntu..."
Best Experience
For full terminal session capture (commands + outputs):
# Install tmux
sudo apt install tmux # Ubuntu/Debian
sudo dnf install tmux # Fedora
brew install tmux # macOS
# Start tmux
tmux
# Now run gpt - it captures your entire session!
gpt
Without tmux/screen, it falls back to command history only.
Support
For issues, questions, or contributions, please visit the
GitHub Repository
Commands
image:To generate images, start a prompt withimage:historyTo view your chat history, typehistorymodelsTo get a list of the models available at OpenAI API, typemodelsmodel:To view all the information on a specific model, start a prompt withmodel:and the modelidcommand:To get a command with the specified functionality and run it, just typecommand:and explain what you want to achieve
Chat context
- Enable chat context mode for the model to remember your previous chat questions and answers. Start the script with
-cor--chat-context.
Set chat initial prompt
- Set your own initial chat prompt with
-ior--init-prompt
Example:gpt -i "You are Rick from Rick and Morty, reply with references to episodes."
Use the official ChatGPT model
- The default model used is
gpt-4o-mini.
Use GPT-4
- If you have access to the GPT-4 model you can use it by setting the model to
gpt-4, i.e.gpt --model gpt-4
Set request parameters
- To set request parameters:
gpt --temperature 0.9 --model text-babbage:001 --max-tokens 100 --size 1024x1024- temperature,
-tor--temperature - model,
-mor--model - max number of tokens,
--max-tokens - image size,
-sor--size - prompt,
-por--prompt - prompt from a file,
--prompt-from-file
- temperature,
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gpt_shell_4o_mini-1.1.0.tar.gz.
File metadata
- Download URL: gpt_shell_4o_mini-1.1.0.tar.gz
- Upload date:
- Size: 25.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a8998ff2617454d6e63acabc10ca28e277ee1561dbbc97395e47be95564db79
|
|
| MD5 |
d6a90518580cd3d791b9e3eeee4a7d9f
|
|
| BLAKE2b-256 |
c4fdffa9d30ba7c36e36701dbab13e111ad8cd76f1ad302fec3fbaa688e52831
|
File details
Details for the file gpt_shell_4o_mini-1.1.0-py3-none-any.whl.
File metadata
- Download URL: gpt_shell_4o_mini-1.1.0-py3-none-any.whl
- Upload date:
- Size: 20.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a314b49390fe4ace3698cf0ec75e9e3c5f00e9ea35edd1c3d4cc37195b3fa604
|
|
| MD5 |
8d3acf3282f1f757630b5ca7e313f4cd
|
|
| BLAKE2b-256 |
3fe8cc8f0ee2fe12fd8afacf11a6e931d2f055385dfbf0a13d8a6c3e8b4161d8
|