GithubHelp home page GithubHelp logo

luk-pio / nlterm Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 70.87 MB

nlterm is a command-line tool that translates natural language descriptions into terminal commands.

Home Page: https://github.com/luk-pio/nlterm

License: MIT License

JavaScript 10.38% TypeScript 89.62%
cli gpt-35-turbo gpt-4 natural-language-processing terminal

nlterm's Introduction

๐Ÿค– nlterm ๐Ÿค–

nlterm is a command-line tool that translates natural language descriptions into terminal commands. Just tell it what you want to do in plain English, and watch it unleash the power of OpenAI to turn your words into executable commands. It's like having an AI-powered rubber duck ๐Ÿฆ†.

nlterm demo screencast

Table of Contents

Prerequisites

Installation

You have two options:

  1. Install it globally using npm:
npm i -g nlterm
  1. Pull the repository and run:
npm run build

This will output a binary for your system (currently supported for linux and macos) to the bin directory, which you can then add to a location in your PATH.

Usage

Using nlterm is simple:

nlterm "what I want to do but can't remember the command for"

The program will then write the translated terminal command to stdout.

Flags:

--debug:      Provides extra debugging info
-h, --help:   Prints the help docs

Executing the commands

If you want to execute the translated terminal command, you can add the following shell function to your shell profile file (~/.bashrc, ~/.bash_profile, or ~/.zshrc):

โš ๏ธ This will execute arbitrary code written by an AI in your shell environment ๐Ÿ’€ Who knows what it's thinking. Use with caution.

function nltermx() {
    if [[ -z "$1" ]]; then
        nlterm -h
        exit 1
    fi

    result=$(nlterm "$1")

    echo "$result"
    echo
    echo -n "Execute? (y/n): "
    read -r answer

    if [[ "$answer" == "y" ]]; then
        source <(echo "$result")
    else
        echo "Aborted."
        exit 0
    fi
}

Setting the API Key

In order to use nlterm, you'll need to set your OpenAI API key as an environment variable in your shell environment. Here's how:

  1. Open your shell profile file (usually ~/.bashrc, ~/.bash_profile, or ~/.zshrc) in a text editor.
  2. Add the following line at the end of the file:
export OPENAI_API_KEY="your_api_key"

Replace your_api_key with your actual API key obtained from OpenAI ๐Ÿ”‘.

  1. Save and close the file.
  2. Restart your terminal or run source ~/.bashrc, source ~/.bash_profile, or source ~/.zshrc, depending on which file you edited.

Examples

$ nlterm "create a new directory called projects"
mkdir projects

$ nlterm "list all files and directories in the current directory"
ls -la

$ nlterm "list all files in the s3 bucket 'my-bucket' with the extension .json"
aws s3 ls s3://my-bucket --recursive | grep ".json$" | awk '{print $4}'

Contributing

You are welcome to contribute to nlterm ๐ŸŽ‰. To get started, please fork the repository and submit a pull request with your proposed changes.

License

nlterm is released under the MIT License ๐Ÿ“œ. See LICENSE for more information.

nlterm's People

Contributors

github-actions[bot] avatar luk-pio avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

nlterm's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.