← Back to Discover

ShellGPT

Python command-line tool that sends prompts to large language models to answer questions, generate shell commands and code, and keep chat sessions going from the terminal.

Command-line tools

What it does

ShellGPT installs with pip and provides the sgpt command. Prompts can come from arguments, stdin or redirection, so you can pipe in a git diff, logs or a document along with an instruction. A --shell option generates a command for your operating system and shell and asks whether to execute, describe or abort, and --code returns code only. Chat and REPL modes keep a named conversation so earlier answers can be refined. Optional shell integration places a suggested command on the terminal input line with a hotkey. Custom roles and user-defined functions let the model run tools on your machine, and the page warns that the model might execute destructive commands, so use is at your own risk. By default it calls OpenAI's API and needs an API key. Running open-source models locally, for example through Ollama, is described as an alternative, although the page notes the tool is not optimized for local models. The project is MIT licensed and supports Linux, macOS and Windows.

Capabilities

  • Shell command generation with an execute, describe or abort prompt
  • Code-only output mode
  • Accepts input from stdin, pipes and redirection
  • Chat and REPL sessions with saved history
  • Custom roles and function calling
  • Hotkey shell integration for Bash and Zsh

When to use it

  • Looking up shell syntax without leaving the terminal
  • Analysing logs or summarising files by piping them into a prompt
  • Generating a quick script or code snippet from the command line