shellcheck-gpt

command module
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2023 License: MIT Imports: 15 Imported by: 0

README

shellcheck-gpt

shellcheck-gpt

Instantly enhance and optimize shell scripts with the power of ShellCheck and LLMs.

semver tag build status license


Demo

Alt Text

Access screencast directly here.

See example directory to see script contents before and after.

Getting started

Prerequisites

  • ShellCheck should be installed and in your PATH.
  • An active OpenAI API key.

Installation

Homebrew
brew install kkyr/tap/shellcheck-gpt
Pre-built binaries

Download the latest release and add the executable to your PATH.

Build using Go toolchain
go install github.com/kkyr/shellcheck-gpt

Usage

Add your OpenAI API key to the environment:

export OPENAI_API_KEY=replace-with-your-api-key

Run shellcheck-gpt against a script:

shellcheck-gpt script.sh

This will:

  1. Run shellcheck against script.sh
  2. Feed the contents of the script and the output of shellcheck into an OpenAI LLM and ask it to make corrections
  3. Write the LLM's output to stdout

[!WARNING]
The entire content of your script is sent in cleartext to OpenAI.

If you'd like to instead write the output back into the script, use the -w flag:

shellcheck-gpt -w script.sh

Note that this will ovewrite any contents already in the script.

Configuration

By default, shellcheck-gpt uses the gpt-3.5-turbo model. You change model using the -m flag:

shellcheck-gpt -m gpt-4-turbo script.sh

See available options and models using the --help flag:

shellcheck-gpt --help

Contributing

Contributions are welcome!

Areas for improvement:

  • Use shellcheck -f diff -p1 to apply fixes that can be automatically applied before calling into LLM.
  • Support more LLMs
  • Add verbose flag to print LLM input/output

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL