npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nlterm

v0.5.1

Published

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

Downloads

4

Readme

🤖 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

  • node >= 14
  • An OpenAI API key 🔐. You can get one by visiting this URL: https://platform.openai.com/account/api-keys See Setting the API Key for more information.

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.