SuperAPIAI Directory

shell_gpt

github.com · AI developer platforms

Discover ShellGPT — Generate command-line help, code and documentation with language models.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsmacOS · Linux

About this tool

ShellGPT is a command-line productivity tool powered by AI large language models (LLMs), designed to help users complete tasks faster and more efficiently. It provides simplified shell commands, code snippets, and documentation generation without the need for external resources (such as Google search). It supports Linux, macOS, and Windows, and is compatible with mainstream shells such as PowerShell, CMD, Bash, and Zsh.

Key Capabilities

  • Generate Shell Commands: Use the --shell or -s option to generate and execute commands based on the current operating system and shell type. For example, requesting a system update on macOS will return a command suitable for macOS; on Ubuntu, a different suggestion will be returned.
  • Generate Code: Use the --code or -c parameter to request pure code output, and the output can be redirected to a file or input can be passed through a pipe.
  • Generate Documentation: Can generate documentation content; the specific usage is not described in detail in the materials.
  • Analyze Logs: Log content can be passed via standard input, and combined with a prompt to quickly analyze logs, identify errors, and obtain suggested solutions.
  • Conversation Feature: Supports chat mode (--chat) and REPL mode (--repl), and can retain and review conversations. Chat sessions are stored in the configurable CHAT_CACHE_PATH. You can use --list-chats to list sessions, and--show-chat to display messages from a specific session.
  • Function Calling: Allows the LLM to execute functions in the system to accomplish various tasks. Default functions can be installed, or custom ~/.config/shell_gpt/functions to define functions. Note that the LLM may execute destructive commands, and you bear the risk yourself.
  • Custom Roles: Use .py files can be created in --create-role to create custom roles for generating code, shell commands, or meeting specific needs. Role files are stored in ~/.config/shell_gpt/roles. You can use --list-roles to list roles, and--show-role to display role details. If the role description contains "APPLY MARKDOWN" (case-sensitive), the chat will be displayed in Markdown format unless --no-md is used to turn it off.
  • Caching: Use --cache(default) and --no-cache to control caching. Identical queries will return results instantly from the local cache. If a different --temperature or --top-probabilityis specified, a new request will be made.
  • Shell Integration: Run sgpt --install-integration to install; it takes effect after restarting the terminal. A few lines will be added to .bashrc or .zshrc . By default, Ctrl+l is used to invoke ShellGPT, replacing the current input line with the suggested command, which can be edited and executed by pressing Enter.

Usage

  • Installation: The materials do not provide specific installation commands, so none are provided for now.
  • Configuration: By default, it uses the OpenAI API and the GPT-4 model, and requires an API key, which is stored in ~/.config/shell_gpt/.sgptrc. The OpenAI API is not free; refer to OpenAI pricing for prices. Open-source models can also be run through local backends such as Ollama (free), but ShellGPT is not optimized for local models and may not work as expected.
  • Input: Accepts standard input and command-line arguments. Input can be passed using pipes and redirection operators.
  • Options:--no-interaction disables interactive mode and prints the generated command to standard output, making it easy to pass through a pipe (for example, using pbcopy to copy to the clipboard).
  • Multiline Prompts: Use triple quotes """.
  • REPL mode: an initial prompt can be passed as an argument, via standard input, or both at the same time.
  • Runtime configuration file:~/.config/shell_gpt/.sgptrc parameters can be set, such as DEFAULT_COLOR(possible values: black, red, green, yellow, blue, magenta, cyan, white, bright_black, bright_red, bright_green, bright_yellow, bright_blue, bright_magenta, bright_cyan, bright_white),CODE_THEME(see Pygments styles),MARKDOWN_LIVE_VERTICAL_OVERFLOW(possible values: ellipsis, visible, crop). The default behavior is ellipsis, where only "..." is shown when the Markdown output exceeds the terminal height. visible mode is recommended for REPL sessions, allowing all generated Markdown content to be viewed in real time.
  • Docker: the container can be run using the OPENAI_API_KEY environment variable and a Docker volume to store the cache. The OS_NAME and SHELL_NAME environment variables can be set according to preference. You can also build your own image using the provided Dockerfile.

Use cases

  • Quickly generate and look up shell commands, avoiding the need to search online for syntax.
  • Generate git commit messages based on a diff.
  • Analyze logs and get solutions for errors.
  • Generate code snippets and save them to a file.
  • Iteratively improve suggestions through conversation.
  • Get command suggestions directly in the terminal via a keyboard shortcut.

Limitations

  • Uses the OpenAI API by default, which is not free and requires an API key.
  • Local models (such as Ollama) are not optimized and may not work as expected.
  • Function calls may execute destructive commands, so use with caution.
  • The materials do not provide specific installation commands, pricing, platform compatibility details, etc., so these are not provided for now.
Up/Down to navigate · Enter to open · ESC to closeBrowse all tools