Skip to content

tott/zsh-ai-complete

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

AI Zsh Completion & Command Expansion

This plugin provides a Zsh completion and command expansion widget for natural language shell command generation using OpenAI-compatible APIs.

Features

  • Type AI <your request> and press TAB to replace your buffer with a shell command generated by OpenAI.
  • Supports multi-line command output, joining them with ;.
  • Works with OpenAI and Azure OpenAI compatible APIs.

Requirements

  • curl
  • jq
  • An OpenAI API key (set as the OPENAI_API_KEY environment variable)

Installation

  1. Copy the script
    Place zsh-completions/_ai in a directory included in your $fpath, e.g. ~/.zsh/completions.

  2. Add to your fpath
    In your .zshrc, add:

    fpath=(~/.zsh/completions $fpath)
  3. Set your API key
    Export your OpenAI API key in your .zshrc:

    export OPENAI_API_KEY=sk-...
  4. Reload your shell
    Restart your terminal or run:

    source ~/.zshrc

Usage

  • Type:

    AI <describe your shell task>
    

    and press TAB.

  • The buffer will be replaced with the generated shell command(s).

Customization

  • To use a different keybinding, change the bindkey line at the end of the script.
  • You can set OPENAI_API_BASE, OPENAI_API_URL, or OPENAI_MODEL to customize the API endpoint or model.

Troubleshooting

  • If no command is generated, check ~/.ai_last_response.json for the raw API response.
  • Ensure your API key is valid and you have network connectivity.

License

MIT License

About

Simple AI Autocompletion for zsh

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors