ShellGPT
CLI that sends prompts to LLMs (OpenAI by default, Ollama supported) to generate shell commands, code, and answers, with stdin piping and chat sessions.
ShellGPT (sgpt) is a command-line client for large language models. It takes a prompt from command-line arguments, stdin, or redirection operators (<, heredocs, <<<) and returns generated shell commands, code snippets, or plain answers. It uses OpenAI's API by default, with the key stored in ~/.config/shell_gpt/.sgptrc. Local models can be run through a backend such as Ollama, though the README notes the tool is not optimized for local models. It supports Linux, macOS, and Windows, and works with shells including PowerShell, CMD, Bash, and Zsh.
The --shell (-s) option generates a command suited to your OS and $SHELL, then prompts to [E]xecute, [D]escribe, or [A]bort. For example, "update my system" yields a softwareupdate command on macOS and an apt command on Ubuntu. --no-interaction prints the command to stdout so it can be piped, for instance to pbcopy. The --code (-c) option returns code only, which can be redirected to a file. Piped input works with both modes, such as git diff | sgpt "Generate git commit message, for my changes" or docker logs -n 20 my_app | sgpt "check logs, find errors, provide possible solutions".
Shell integration, installed with sgpt --install-integration, adds lines to .bashrc or .zshrc. Pressing Ctrl+l by default replaces the current input line with a suggested command, which you can edit before running. For conversation state, --chat <name> keeps a named session that can be combined with --code or --shell to refine output over several prompts. --repl <name> opens an interactive loop on the same session object, with multiline input using triple quotes. --list-chats and --show-chat list and inspect sessions. The tool suits developers and sysadmins who want to look up command syntax, draft snippets, or analyze logs and diffs without leaving the terminal.
Installation
# via pip
pip install shell-gpt

Alternatives & related tools
llm
CLI tool and Python library for interacting with OpenAI, Anthropic, Google, and dozens of other language models via APIs or locally
aider
AI-powered terminal-based pair programming tool that integrates LLMs with your existing codebase and git workflow
Open Interpreter
CLI tool that lets LLMs execute code locally through a ChatGPT-like terminal interface with approval prompts
AIChat
LLM CLI with a shell assistant, chat REPL, RAG, function calling and agents, supporting 20+ providers including OpenAI, Claude, Gemini and Ollama.
Claude Squad
Terminal UI that runs multiple AI coding agents (Claude Code, Codex, Gemini, Aider) in parallel, each in its own tmux session and git worktree.
add a badge to your README
Maintain ShellGPT? Show that it's featured on trmn. The badge links back to this page.
[](https://www.trmn.sh/tools/shell-gpt?utm_source=badge)<a href="https://www.trmn.sh/tools/shell-gpt?utm_source=badge"><img src="https://www.trmn.sh/badge/shell-gpt.svg" alt="Featured on trmn" height="20"></a>