Zsh Codex: AI in the Command Line
Zsh Codex is an innovative plugin developed for ZSH (Z Shell), which brings the power of AI to the command line, specifically designed for enhancing code completion. This tool leverages the advanced AI capabilities of OpenAI's Codex and Google's Generative AI, known as Gemini, to assist users in coding more efficiently. Codex serves as the engine behind GitHub Copilot, providing coding assistance by generating code snippets. Gemini, on the other hand, is one of Google's latest language models, offering similar functionality.
Key Features
-
AI-Powered Code Completion: Zsh Codex enables users to write a comment or variable name, and the AI generates the corresponding code, reducing time spent on crafting repetitive coding structures.
-
Integration with OpenAI and Google AI: It supports both OpenAI's and Google's AI models, allowing users to select the one that best fits their needs.
-
Customizable Configuration: Users can configure various services with specific API keys and model choices to fine-tune how the AI interacts with their command line environment.
Installation Instructions
Manual Installation
To manually install Zsh Codex, users need to follow a series of straightforward steps:
-
Install Necessary Python Packages: Users need to install either the OpenAI or Google Generative AI package via pip:
pip3 install openai
or
pip3 install google-generativeai
-
Clone the Plugin Repository: Download the ZSH plugin using Git:
git clone https://github.com/tom-doerr/zsh_codex.git ~/.oh-my-zsh/custom/plugins/zsh_codex
-
Update ZSH Configuration: Add the plugin to your
.zshrc
file:- If using Oh My Zsh:
plugins=(zsh_codex) bindkey '^X' create_completion
- Without Oh My Zsh:
export ZSH_CUSTOM="your/custom/path" source "$ZSH_CUSTOM/plugins/zsh_codex/zsh_codex.plugin.zsh" bindkey '^X' create_completion
- If using Oh My Zsh:
-
Create a Configuration File: At
~/.config/zsh_codex.ini
, define the service configuration:[service] service = groq_service [openai_service] api_type = openai api_key = <openai_apikey> [groq_service] api_type = groq api_key = <groq_apikey> model = gemma2-9b-it
-
Run Zsh: Start using the plugin by launching Zsh and utilizing
^X
to activate completion. -
Virtual Environments: If using virtual environments, set the Python executable path where the necessary packages are installed.
Fig Installation
Alternatively, installation through Fig is supported for those using the Fig plugin manager. Interested users can easily add Zsh Codex through Fig's platform.
Troubleshooting Common Issues
-
Unhandled ZLE Widget Error: If you encounter this error, add the line
zle -N create_completion
before thebindkey
command. -
Directory Already Exists: If an existing directory error occurs during the install, it is advisable to retry the cloning step.
Support and Contributions
Users are encouraged to engage with the project by leaving feedback via issues on GitHub. Additional support or contributions can be shown through platforms like "Buy Me A Coffee."
Additional Resources
For those interested in different implementations or extensions, a version for the Fish shell is available, as well as traffic statistics and updates on the project's growth.
Zsh Codex is a testament to the advancement of integrating AI capabilities directly into development environments, significantly boosting productivity and coding efficiency.