ShellGPT is a Python-based CLI tool that generates shell commands, code, and documentation using LLMs. It supports local and OpenAI models, shell integration, code generation, chat, REPL, function calls, and role management.
Collecting history — the radar snapshots this repo daily. The trend line appears after 3 days of data (1 so far).
What it is
ShellGPT is a command-line productivity tool powered by AI large language models. It offers streamlined generation of shell commands, code snippets, and documentation, and supports Linux, macOS, Windows, with compatibility across major shells.
Getting started
Installation:
pip install shell-gpt
OpenAI API is used by default with GPT-4 model; an API key is required and stored in ~/.config/shell_gpt/.sgptrc.
Alternatively, you can run open-source models locally using Ollama.
Usage examples:
sgpt "What is the fibonacci sequence"
sgpt accepts prompts from stdin or command line arguments, and you can generate shell commands, code, or perform analysis of logs or diffs as shown in the examples.
Shell integration
Install integration:
sgpt --install-integration
Restart terminal to apply changes. This adds lines to .bashrc or .zshrc and enables Ctrl+l to invoke ShellGPT.
Generating code
Use the --code or -c parameter to request pure code output:
sgpt --code "solve fizz buzz problem using python"
Chat Mode and REPL
ShellGPT supports chat sessions via --chat and REPL via --repl, with options to list, show, and manage chats. A configurable chat cache path stores sessions.
Function calling
Function calling is available. Install default functions:
sgpt --install-functions
You can define custom functions by creating Python files under ~/.config/shell_gpt/functions and referencing them through prompts.
Roles
You can create roles with:
sgpt --create-role json_generator
This README provides many prompts and examples showing how to generate commands, code blocks, and interactions with LLMs. The latest releases show updates to litellm integration and model defaults, with multiple version entries listed in the changelog.






