shellgpt

shellgpt

Chat with LLM in your terminal, be it shell generator, story teller, linux-terminal, etc.

Stars: 60

Visit
 screenshot

ShellGPT is a tool that allows users to chat with a large language model (LLM) in the terminal. It can be used for various purposes such as generating shell commands, telling stories, and interacting with Linux terminal. The tool provides different modes of usage including direct mode for asking questions, REPL mode for chatting with LLM, and TUI mode tailored for inferring shell commands. Users can customize the tool by setting up different language model backends such as Ollama or using OpenAI compatible API endpoints. Additionally, ShellGPT comes with built-in system contents for general questions, correcting typos, generating URL slugs, programming questions, shell command inference, and git commit message generation. Users can define their own content or share customized contents in the discuss section.

README:

ShellGPT

Chat with LLM in your terminal, be it shell generator, story teller, linux-terminal, etc.

Install

pip install -U shgpt

Or install latest version

pip install --force-reinstall -U git+https://github.com/jiacai2050/shellgpt.git

This will install two commands: sg and shellgpt, which are identical.

After install, use sg --init to create required directories(mainly ~/.shellgpt).

Usage

ShellGPT has three modes to use:

  • Direct mode, sg [question] or pipeline like echo question | sg.
  • REPL mode, sg -r, chat with LLM.
  • TUI mode, sg -t, tailored for infer shell command.

Model

By default, shellgpt uses Ollama as its language model backend, requiring installation prior to usage.

Alternatively, one can set up shellgpt to utilize OpenAI compatible API endpoints:

export SHELLGPT_API_URL=https://api.openai.com
export SHELLGPT_API_KEY=<token>
export SHELLGPT_MODEL='gpt-3.5-turbo'

# or Cloudflare Worker AI
export SHELLGPT_API_URL=https://api.cloudflare.com/client/v4/accounts/<account-id>/ai
export SHELLGPT_API_KEY=<token>
export SHELLGPT_MODEL='@cf/meta/llama-3-8b-instruct'

See conf.py for more configs.

TUI

There are 3 key bindings to use in TUI:

  • ctrl+j, Infer answer
  • ctrl+r, Run command
  • ctrl+y, Yank command

TUI screenshot

System contents

There are some built-in system contents in shellgpt:

  • default, used for ask general questions
  • typo, used for correct article typos.
  • slug, used for generate URL slug.
  • code, used for ask programming questions
  • shell, used for infer shell command
  • commit, used for generate git commit message, like git diff | sg -c commit

Users can define their own content in ~/.shellgpt/contents.json, it a JSON map with

  • key being content name and
  • value being content body

Or you can just copy contents.json to play with, it's generated from Awesome ChatGPT Prompts.

$ sg -c linux-terminal pwd
/home/user

$ sg -c javascript-console 0.1 + 0.2
0.3

Users can share their customized contents in discuss section.

License

GPL-3.0

For Tasks:

Click tags to check more tools for each tasks

For Jobs:

Alternative AI tools for shellgpt

Similar Open Source Tools

For similar tasks

For similar jobs