How to do bash commands you always forget. OpenAI-powered.

  • By Vlad Lialin
  • Last update: Dec 7, 2022
  • Comments: 2

Howto

Howto is a GPT-3/Codex-powered shell tool that allows you to talk with your shell in natural language.

Howto demo

Forgot how to create a conda environment?

% howto create conda env
conda create -n <env_name> python=3.6

Forgot how to add a new env to Jupyter?

% howto add kernel to jupyter
python -m ipykernel install --user --name=

Want to download the biggest Rick Astley's hit?

% howto download youtube video for never give you up
youtube-dl -f 18 https://www.youtube.com/watch?v=dQw4w9WgXcQ

Howto can also suggest how to be a nicer person

 % howto be a nicer person
alias please='sudo'

It works by sending requests to OpenAI API. Lookup Environment Variables section on how to set up the API key.

Installation

Option 1: Download the binary from Github

OS Architecture Link
Linux x86_64 howto-linux-x86_64
MacOS x86_64 (Intel) howto-darwin-x86_64
MacOS arm64 (M1) howto-darwin-arm64
Windows x86_64 howto-windows-x86_64

Full list of architectures can be found on the release page.

Then untar it and add it to your PATH. For example:

tar -xvf howto-v1.0.1-darwin-amd64.tar.gz
mv howto /usr/local/bin/

moving the binary to /usr/local/bin can require sudo rights

Option 2: Build from source

If you have Go installed, you can build the binary from source.

go build

if you have your $GOPATH/bin in your path, just run go install . to install the binary

Then move the binary to your path, e.g., mv howto /usr/local/bin/

Environment variables

You need to connect your OpenAI API key to the program by setting the OPENAI_API_KEY environment variable. Get your OpenAI API key here.

export OPENAI_API_KEY=<your_api_key>

By default we use text-davinci-002, you can change it to a different model by setting the HOWTO_OPENAI_MODEL environment variable. It's best to use Codex models (e.g., code-davinci-002), but code models are currently in beta and not available to everyone.

export HOWTO_OPENAI_MODEL=<model_to_use>  # optional, default is text-davinci-002

Disclaimer

Howto suggestions are generated by an AI model and are not guaranteed to be safe to execute or to be executable at all. Please use common sense when using the suggested commands.

Download

howto.zip

Comments(2)

  • 1

    429 too many requests

    On windows, this is the only output i get:

    OpenAI API disn't respont correctly. Did you correctly set you OPENAI_API_KEY?
    Response:  &{429 Too Many Requests 429 HTTP/2.0 2 0 map[Content-Length:[206] Content-Type:[application/json; charset=utf-8] Date:[Sun, 23 Oct 2022 17:11:18 GMT] Strict-Transport-Security:[max-age=15724800; includeSubDomains] Vary:[Origin] X-Request-Id:[2abfcad18cb5b52bdcdbb5b77d3196b8]] 0xc0000a2b80 206 [] false false map[] 0xc00010a100 0xc0000e8420}
    

    I dont have any tokens tho, so i expected to have an error related to usage limit. So i think it's either something in your code, or its something in openai's stuff

  • 2

    improvements

    minor code improvements - removed manual bash command concatenating, removed some useless byte-string/string-byte conversions, added os.Exit(1) in error handlers (this is possibly a bug fix)