GithubHelp home page GithubHelp logo

tom-doerr / zsh_codex Goto Github PK

View Code? Open in Web Editor NEW
1.4K 17.0 67.0 55 KB

This is a ZSH plugin that enables you to use OpenAI's Codex AI in the command line.

License: MIT License

Python 86.47% Shell 13.53%
zsh openai codex ai

zsh_codex's Introduction

⌨️ 🦾 Zsh Codex

AI in the command line.

Repository's starts Issues License
Latest commit GitHub repository size

You just need to write a comment or variable name and the AI will write the corresponding code.

What is it?

This is a ZSH plugin that enables you to use AI powered code completion in the command line. It now supports both OpenAI's Codex and Google's Generative AI (Gemini). OpenAI Codex is the AI that also powers GitHub Copilot, while Gemini is Google's advanced language model.

How do I install it?

Manual Installation

  1. Install the OpenAI package or the Google package.
pip3 install openai

or

pip3 install google-generativeai
  1. Download the ZSH plugin.
git clone https://github.com/tom-doerr/zsh_codex.git ~/.oh-my-zsh/custom/plugins/zsh_codex 
  1. Add the following to your .zshrc file.

Using oh-my-zsh:

    plugins=(zsh_codex)
    bindkey '^X' create_completion

Without oh-my-zsh:

    # in your/custom/path you need to have a "plugins" folder and in there you clone the repository as zsh_codex
    export ZSH_CUSTOM="your/custom/path"
    source "$ZSH_CUSTOM/plugins/zsh_codex/zsh_codex.plugin.zsh"
    bindkey '^X' create_completion
  1. Create a file called openaiapirc in ~/.config with your SECRET_KEY.
[openai]
secret_key = ...

or Create a file called geminiapirc in ~/.config with your SECRET_KEY.

[gemini]
api_key = ...

You can also optionally specify: organization, base_url, model and temperature.

  1. Set the LLM which you are going to use (you can choose between openai and gemini).
nano ~/.oh-my-zsh/custom/plugins/zsh_codex/zsh_codex.plugin.zsh

Set the api variable to openai or gemini.

  1. Run zsh, start typing and complete it using ^X!

  2. If you use virtual environments you can set ZSH_CODEX_PYTHON to python executable where openai or google-generativeai is installed. e.g. for miniconda you can use:

export ZSH_CODEX_PYTHON="$HOME/miniconda3/bin/python"

Fig Installation

Troubleshooting

Unhandled ZLE widget 'create_completion'

zsh-syntax-highlighting: unhandled ZLE widget 'create_completion'
zsh-syntax-highlighting: (This is sometimes caused by doing `bindkey <keys> create_completion` without creating the 'create_completion' widget with `zle -N` or `zle -C`.)

Add the line

zle -N create_completion

before you call bindkey but after loading the plugin (plugins=(zsh_codex)).

Already exists and is not an empty directory

fatal: destination path '~.oh-my-zsh/custom/plugins'

Try to download the ZSH plugin again.

git clone https://github.com/tom-doerr/zsh_codex.git ~/.oh-my-zsh/custom/plugins/zsh_codex

Buy Me A Coffee

More usage examples


Fish Version

Traffic Statistics

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.