Introduction to gptsh
gptsh is a cross-platform command-line interface (CLI) tool designed to ease the process of using shell commands. Built with NodeJS and powered by Open AI's GPT-3, it converts natural language inputs or queries into precise shell commands. The tool draws inspiration from similar projects like nlsh and cmdxyz, ensuring it integrates seamlessly into traditional shell environments.
Purpose
The main goal of gptsh is not to replace shell commands entirely but to aid users in tasks where commands are not easily remembered. It provides a convenient way to perform generic tasks such as compressing files, navigating frameworks, or searching system files, enhancing the efficiency of shell operations.
Demonstration
For a visual understanding, gptsh offers a demonstration via a GIF, accessible on its GitHub page. This exemplifies the straightforward conversion of user instructions into shell commands.
Installation
Installing gptsh is straightforward. Users can choose between using the Node Package Manager (NPM) or Yarn. Either of the commands below will install gptsh globally:
npm install --global gptsh
yarn global add gptsh
Alternatively, for those who prefer Docker, running the shorwood/gptsh
Docker image is an option. Here are sample commands utilizing Docker:
docker run --rm -e OPENAI_SECRET_KEY shorwood/gptsh <input>
docker run --rm shorwood/gptsh <input> -s <YOUR_SECRET_KEY>
Additionally, to streamline usage, users can create an alias for gptsh:
$ alias gptsh='docker run --rm -e OPENAI_SECRET_KEY shorwood/gptsh'
$ gptsh Reset Nginx
sudo service nginx restart
Getting Started
To start using gptsh, users need to set an OpenAI API key. This can be defined as an environment variable:
OPENAI_SECRET_KEY=<YOUR_SECRET_KEY>
OPENAI_ENGINE_ID=davinci
Alternatively, the key can be an option passed during execution:
gptsh <input> --secret <YOUR_SECRET_KEY>
Or specified in the ~/.gptshrc
configuration file within the user's home directory:
secret=sk-XckwVRipQyM9nr1M8jVGGBUvDGIqwVmsbcrznkwz
engine=davinci
platform=linux
Usage
gptsh has a simple usage format:
gptsh <input> [options]
Some of the options available include:
- --version: Shows the version number.
- -s, --secret: Specifies the OpenAI API key.
- -e, --engine: ID of the engine to use.
- -t, --tokens: Maximum number of tokens to consume (default is 100).
- --temperature: Affects the risk level of the model (default is 0.0).
- -p, --platform: Command output platform.
- -n: Number of completions to generate.
- --help: Displays help information.
Examples
Here are a few practical examples of gptsh in action:
$ gptsh install node 12 repository
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
$ gptsh add yarn bin folder to path on zsh
echo 'export PATH="$HOME/.yarn/bin:$PATH"' >> ~/.zshrc
$ gptsh List all files of this directory | bash
LICENSE data node_modules package.json src yarn.lock
$ gptsh Install the lodash package using yarn --secret <YOUR_SECRET_KEY>
yarn add lodash
$ gptsh Delete the root directory --engine ada
rm -rf /
$ gptsh Add remote from github with name shorwood/gptsh
git remote add shorwood https://github.com/shorwood/gptsh.git
gptsh is versatile and can be used across different platforms, including Windows and UNIX systems:
PS C:\WINDOWS\system32> gptsh Add a new user --platform win32
Add-ADUser -Name "username" -SamAccountName username -AccountPassword (Read-Host -AsSecureString "Password") -Enabled $true -ChangePasswordAtLogon $false
$ gptsh Add a new user --platform aix
mkuser username
Contributing
Contributions to gptsh are welcome. For major changes, it's recommended to open an issue first to discuss potential adjustments.
License
gptsh is licensed under the MIT License, ensuring open and accessible usage. More details can be found at MIT License.