Giter VIP home page Giter VIP logo

shell-genie's Introduction

I am no longer maintaining this repository. Please consider using a tool such as shellGPT

๐Ÿงžโ€โ™‚๏ธ Shell Genie

Your wishes are my commands.

Shell Genie is a command-line tool that lets you interact with the terminal in plain English. You ask the genie what you want to do and it will give you the command you need.

Installation

The recommended way to install Shell Genie is using pipx:

  1. Install Python 3.10 or higher.
  2. Install pipx.
  3. Install Shell Genie: pipx install shell-genie

Alternatively, you can install it using pip:

  1. Install Python 3.10 or higher.
  2. Create a virtual environment in your preferred location: python -m venv .venv
  3. Activate the virtual environment: source .venv/bin/activate
  4. Install Shell Genie: pip install shell-genie

How to use

  1. First, you need to initialize the tool by running the following command:

    shell-genie init

    This will prompt you to select a backend (either openai-gpt3.5-turbo or free-genie) and provide any additional information that is required (e.g. your own OpenAI API key for openai-gpt3.5-turbo).

    The free-genie backend is free to use. I'm hosting it, and as you can imagine I'm not a big corporation with unlimited money, so there's no guarantee that it will be available at all times. My goal is to generate a dataset of commands to fine-tune a model later on (this is mentioned during the initialization process).

  2. Once you have initialized the tool, you can start asking the genie what you want to do. For example, you may ask it to find all the json files in the current directory that are larger than 1MB:

    shell-genie ask "find all json files in the current directory that are larger than 1MB"

    You'll see an output similar to this:

    Command: find . -name "*.json" -size +1M
    Do you want to run this command? [y/n]:

    If you have questions about how the command works, you can ask the genie to explain it:

    shell-genie ask "find all json files in the current directory that are larger than 1MB" --explain

    And you'll see an output similar to this:

    Command: find . -name "*.json" -size +1M
    Description: This command will search the current directory for all... (shortened for brevity)
    Do you want to run the command? [y/n]:

    You can ask for commands in English or other languages, and the genie will try to provide you with a explanation in the same language.

  3. Run the command if you want to. If you're using free-genie, and you want to help improve the tool, you can provide feedback after you've run the command.

Using an alias

If you find that writing shell-genie ask is too verbose, you can create an alias for the tool:

echo "alias please='shell-genie ask'" >> ~/.bashrc
source ~/.bashrc

And now you can ask the genie using please:

please "find all json files in the current directory that are larger than 1MB"

Examples

Here are two short videos showing how to use the tool:

Limitations

As you can imagine, not all the commands provided by the genie work as expected. If you request them, you might receive commands that could wreck your OS (e.g., rm -rf /). So, don't run commands if you don't understand their functions. If you choose to execute them despite not understanding them, do so at your own risk.

License

This project is licensed under the terms of the MIT license.

shell-genie's People

Contributors

dylanjcastillo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shell-genie's Issues

Support for non-english explanations

Currently the shell-genie understands non-english questions but when explain it's explains only in english.

Could do more useful for many non-english speakers to allow the shell-genie to ask the AI to respond in same language of the question or if it's not possible or to maintain more consistent responses to detect the current shell language and ask the AI to respond in that language.

Need help in Deploying this model locally.

Hey @dylanjcastillo

Kudos on your amazing creation! It's working wonders on our machine.
We've got some unique tasks to handle via the CLI, so we're keen on deploying and training this gem locally.
Any chance you could drop some quick steps our way? If any bumps come up, expect a ping from me.

Remove GPT-3.5 Turbo support and add free alternative support

GPT-3.5 Turbo OpenAI API key is no longer free under rate limit. As of March 8, 2023, OpenAI moved the GPT-3.5 Turbo model to their paid tier. This means that you will need to upgrade to a paid plan to use the GPT-3.5 Turbo model, even if you are only using it under the rate limit.

Here are some alternatives to the GPT-3.5 Turbo model that are still free under rate limit:

GPT-3 Ada
GPT-3 Babbage
ChatGPT
You can also try other large language models, such as:

Bard
Jurassic-1 Jumbo
Megatron-Turing NLG

License statement

Currently there is no license statement. Could you please add a LICENSE file that contains the license text or add details to pyproject.toml?

For Nixpkgs shell-genie is marked as unfree for now but a clarification about the license would be much appreciated.

Thanks.

Termux support missing

Platform.py throws an error on android when getting the OS name. Would be nice to have a fallback method to just get "linux" when on android.

--explain

everytime i run for example : shell-genie ask "list file" --explain
i get Error: Error in response.
any idea why ?

Integrate with Bash/ZSH auto-completion

This may end a bit hard to do but could be very usefull to allows shell-genie to works with tabs autocomplete dedution and explanation like for example. If you write "ls -lh" and press tab twice to autocomplete it can comes with the response:
Description: The command 'ls -lh' is used to list the contents of a directory in a long format, with human-readable file sizes. It will display the file permissions, owner, group, size, date, and filename. The '-l' flag stands for 'long' and the '-h' flag stands for 'human-readable'. This command works on macOS-12.6.5 using zsh.

thank you

I learned today much from your suggestion ML tool.
Thank you

Add xonsh shell support

It will be cool to have an ability to set the shell (e.g. https://xon.sh) i.e.:

xonsh
$SHELL_GENIE_SHELL="xonsh"
shell-genie ask "set env variable HELLO with "world" value"  # automatically added "on xonsh"
# Command: $HELLO="world"
# Do you want to run this command? [y/n]:

Opening files through nano with sudo

Whenever trying to open permissioned files through nano using sudo genie gets stuck. I've tried several different ones and none worked. With fstab I couldn't even close it with "ctl+x" and when closing others - for example:

~> shell-genie ask "open grub configuration through nano"
Command: `sudo nano /etc/default/grub`
Do you want to run the command? [y/n]: y
/bin/sh: line 1: $'\E[?2004h\E[?1049h\E[22;0;0t\E[1;21r\E(B\E[m\E[4l\E[?7h\E[39;49m\E[?1h\E=\E[?1h\E=\E[?25l\E[39;49m\E(B\E[m\E[H\E[2J\E[19;34H\E(B\E[0;7m[': command not found

[Proposal] Prevent destructive commands

I'm using a basic bash wrapper for shell-genie, BTW: but this doesn't affect the result, in no way.

Screenshot from 2023-09-03 15-22-57

You can simply ask "Explode my Linux" and ironically it will prompt to do; this kind of behavior should be prevented, returning a sorry message.

/too bad it doesn't work with the latest pyton

Nice!

/too bad it doesn't work with the latest pyton. 3.8.10

PIP STDOUT

PIP STDERR

ERROR: Ignored the following versions that require a different python version: 0.1.0 Requires-Python >=3.10,<4.0; 0.1.1 Requires-Python >=3.10,<4.0; 0.1.2 Requires-Python >=3.10,<4.0; 0.1.3 Requires-Python >=3.10,<4.0; 0.1.4 Requires-Python >=3.10,<4.0; 0.1.5 Requires-Python >=3.10,<4.0; 0.1.6 Requires-Python >=3.10,<4.0; 0.2.0 Requires-Python >=3.10,<4.0; 0.2.1 Requires-Python >=3.10,<4.0; 0.2.10 Requires-Python >=3.10,<4.0; 0.2.2 Requires-Python >=3.10,<4.0; 0.2.3 Requires-Python >=3.10,<4.0; 0.2.4 Requires-Python >=3.10,<4.0; 0.2.5 Requires-Python >=3.10,<4.0; 0.2.6 Requires-Python >=3.10,<4.0; 0.2.7 Requires-Python >=3.10,<4.0; 0.2.8 Requires-Python >=3.10,<4.0; 0.2.9 Requires-Python >=3.10,<4.0

ERROR: Could not find a version that satisfies the requirement shell-genie (from versions: none)
ERROR: No matching distribution found for shell-genie

Support for oracle linux 8.9

pipx install shell-genie returns below.

ERROR: Could not find a version that satisfies the requirement shell-genie (from versions: none)
ERROR: No matching distribution found for shell-genie

[Feature Wish] Faster prompting

As done in other tools, it could be possible to make this faster adding few lines to the .rc file of the shell.

In my case (zsh) I added an alias:

alias please="shell-genie ask"

and then by adding this piece of code in the rc file:

format-and-accept() {
  BUFFER="please \"$BUFFER\""
  zle accept-line
} 

# Bind the function to Ctrl+F
zle -N format-and-accept
bindkey '^F' format-and-accept

it is possible to just write the bare prompt in the shell and then by pressing Ctrl+F it will call the shell-genie.

You could make this possible to enable this feature by adding an option that appends the above lines in the rc file.

Missing config on install

Neat tool :)
I installed with pipx on Arch and got the following error:

FileNotFoundError: [Errno 2] No such file or directory: 
'~/.config/.shell_genie/config.json'

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.