Coder Social home page Coder Social logo

zsh-ai-commands's Introduction

ZSH AI Commands

zsh-ai-commands-demo

This plugin works by asking GPT (gpt-4o) for terminal commands that achieve the described target action.

To use it just type what you want to do (e.g. list all files in this directory) and hit the configured hotkey (default: Ctrl+o). When GPT responds with its suggestions just select the one from the list you want to use.

Requirements

  • curl
  • fzf
    • note: you need a recent version of fzf (the apt version for example is fairly old and will not work)
  • awk

Installation

oh-my-zsh

Clone the repository to you oh-my-zsh custom plugins folder:

git clone https://github.com/muePatrick/zsh-ai-commands ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/zsh-ai-commands

Enable it in your .zshrc by adding it to your plugin list:

plugins=(... zsh-ai-commands ...)

Set the API key in your by setting:

ZSH_AI_COMMANDS_OPENAI_API_KEY="sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

Replace the placeholder with your own key. The config can be set e.g in your .zshrc in this case be careful to not leak the key should you be sharing your config files.

Configuration Variables

Variable Default Description
ZSH_AI_COMMANDS_OPENAI_API_KEY -/- (not set) OpenAI API key
ZSH_AI_COMMANDS_HOTKEY '^o' (Ctrl+o) Hotkey to trigger the request
ZSH_AI_COMMANDS_LLM_NAME gpt-4o LLM name
ZSH_AI_COMMANDS_N_GENERATIONS 5 Number of completions to ask for
ZSH_AI_COMMANDS_EXPLAINER true If true, GPT will comment the command

Known Bugs

  • Sometimes the commands in the response have to much / unexpected special characters and the string is not preprocessed enough. In this case the fzf list stays empty.
  • The placeholder message, that should be shown while the GPT request is running, is not always shown. For me it only works if zsh-autosuggestions is enabled.

zsh-ai-commands's People

Contributors

thiswillbeyourgithub avatar muepatrick avatar devnoname120 avatar

Stargazers

SouL KIM avatar  avatar Tobstar avatar  avatar Alex Roman avatar Fredrik Magnusson avatar Tomislav O avatar  avatar Paul Willot avatar  avatar NT avatar Cybershart avatar

Watchers

 avatar  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.