ShellGPT
Chat with LLM in your terminal, be it shell generator, story teller, linux-terminal, etc.
Install
pip install -U shgpt
or if you prefer to use uvtool
uv tool install shgpt
This will install two commands: sg and shellgpt, which are identical.
After install, use sg --init to create the required directory and a default configuration file (~/.shellgpt/config.toml).
Usage
ShellGPT has three modes:
- Direct mode:
sg [question]or via pipeline:echo question | sg. - REPL mode:
sg --replfor an interactive chat. - TUI mode:
sg --tuifor a text user interface, tailored for shell command inference.
Configuration
ShellGPT is configured via ~/.shellgpt/config.toml. You can change the configuration directory by setting the SHELLGPT_CONF_DIR environment variable.
Multiple Profiles
Define your API settings in the [profiles] section and switch between them using the -p / --profile flag.
# ~/.shellgpt/config.toml
default_profile = "ollama"
[profiles.ollama]
base_url = "http://localhost:11434/v1"
model = "llama3"
[profiles.openai]
base_url = "https://api.openai.com/v1"
# You can provide api_key directly
api_key = "sk-xxxx"
# Or provide the name of the environment variable that contains the API key
# api_key_env = "OPENAI_API_KEY"
model = "gpt-4o"
# Headers support environment variable substitution ($VAR or ${VAR})
headers = { "Authorization" = "Bearer $OPENAI_API_KEY", "X-My-Header" = "value" }
# https://docs.github.com/en/github-models/quickstart
[profiles.github]
base_url = "https://models.github.ai/inference"
api_key = "ghp_xxxx"
model = "gpt-4o"
# https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/
[profiles.cloudflare]
base_url = "https://api.cloudflare.com/client/v4/accounts/<account-id>/ai/v1"
api_key = "<token>"
model = "@cf/meta/llama-3-8b-instruct"
# https://developers.cloudflare.com/ai-gateway/usage/chat-completion/
[profiles.cloudflare-gateway]
base_url = "https://gateway.ai.cloudflare.com/v1/<account-id>/<gateway-id>/compat"
api_key = "sk-xxxx"
model = "gpt-4o"
Usage:
# Uses default_profile (ollama)
sg How to center a div?
# Uses OpenAI profile
sg -p openai Write a poem about rust
Global Settings
You can override global defaults at the top level of the config file:
timeout = 60
stream = true
temperature = 0.8
Roles
Roles allow you to define specific system prompts for different tasks. They are managed in the [roles] section of your config.
Built-in examples (created during sg --init):
shell: Infer shell commands.typo: Correct text typos.code: Coding assistant.summary: Summarize text in Markdown.polish: Polish writing.
Usage:
# List all available roles and their contents
sg --list
# Use a specific role
sg -r typo I is a enginer
git diff | sg -r commit
# Directly configure system prompt
sg --system "You are a translator. Translate to Japanese." Hello world
sg --system-file prompt.txt Hello world
Custom Roles
Add your own roles to config.toml:
[roles]
translator = "You are a professional translator. Translate everything to Japanese."
Then use it with sg -r translator Hello world.
TUI
Key bindings in TUI mode:
ctrl+j: Infer answerctrl+r: Run commandctrl+y: Yank command
License
Metadata
Release files for shgpt 0.7.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| shgpt-0.7.2.tar.gz | 19.0 kB | Without provenance | Details for shgpt-0.7.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| shgpt-0.7.2-py3-none-any.whl | Python 3 | none | any | Details for shgpt-0.7.2-py3-none-any.whl |
Total release size: 36.5 kB
Release files / shgpt-0.7.2.tar.gz
| Download URL | shgpt-0.7.2.tar.gz |
|---|---|
| Size | 19.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7bc8acf5ad27b9b4e630427935280f21e9214363ce2fb5d8018248996ec949ad
|
|
BLAKE2b-256 checksum How to use checksums |
1e0199c8296e2e27af1573768dd3bfcc300106af8e4d01146f8105fdae64556c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / shgpt-0.7.2-py3-none-any.whl
| Download URL | shgpt-0.7.2-py3-none-any.whl |
|---|---|
| Size | 17.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
933c9f44dd5e303957c478256c5ac40dcf8956cb93d990252746855f54236541
|
|
BLAKE2b-256 checksum How to use checksums |
2ffc0fbe801c6bdd1d06c7b0be8a4b39172f7740d237e9e39c9fbbd0f67b0dcb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for shgpt 0.7.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.