Git Product home page Git Product logo

askgpt's Introduction

askgpt

CLI ChatGPT integration for discovering Linux commands or answering random ChatGPT queries.

Askgpt can be used as a stand-alone GPT CLI or plugged-in to zsh (or other shells) in order to act as your CLI assistant.

When configured as below, you can interact with ChatGPT from the command line, and either:

  1. Have it respond to a CLI-related question, putting the linux command in the queue for you to execute, or
  2. Respond to a general question (non-linux related)

Linux CLI commands

Askgpt will attempt to recognize when your query is about a linux command and, when configured properly in zsh, will allow you to execute that command by just pressing enter.

Example:

zsh> ask how do I list all files including hidden
zsh> ls -a  

To accept askgpt's response, press enter. To cancel, backspace over text or press CTRL-C.

Standard ChatGPT requests

If the query appears to be unrelated to a linux command, askgpt will just print the results. You can force the general response by using ai instead of ask

Example:

zsh> ai what is the highest mountain
The highest mountain in the world is Mount Everest.
zsh>

Quoting

Some requests may require quoting the entire string, for instance, when using some punctionation (?,.$). To avoid this, just type ask or ai followed by ENTER. Then type string.

Example:

zsh> ai
ai: what are quotes(") for?

Installation

  1. Clone repository
  2. pipx install ./askgpt

Uninstall

pipx uninstall askgpt

Run from source

  1. poetry install
  2. poetry shell
  3. python3 -m askgpt

Sample .zshrc

OPENAI_API_KEY=[YOUR OPENAI API KEY]
export OPENAI_API_KEY

ASKGPT_PATH=~/Dev/askgpt

ask() {
    if [ $# -eq 0 ]; then
        echo "ask: \c"
        read user_input
        set -- $user_input
    fi

    local cmd=$(askgpt "$@")
    # if askgpt returns NULL it is outside of the CLI domain
    if [[ $cmd == NULL* ]]; then
        print "Outside of CLI domain"
    else
        # Add output to zsh history
        print -z $cmd
    fi
}

ai() {
    if [ $# -eq 0 ]; then
        echo "ai: \c"
        read user_input
        set -- $user_input
    fi
    askgpt -q "$@"
}                          

askgpt's People

Contributors

steverhall avatar

Stargazers

Geoff Petrie avatar

Watchers

 avatar Kostas Georgiou avatar

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.