AI in the command line.
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
- Install the OpenAI package or the Google package.
bash pip3 install openai # or pip3 install google-generativeai
- Download the ZSH plugin.
bash git clone https://github.com/tom-doerr/zsh_codex.git ~/.oh-my-zsh/custom/plugins/zsh_codex
- Add the following to your .zshrc file.
- Using oh-my-zsh:
bash plugins=(zsh_codex) bindkey ^X create_completion
- Without oh-my-zsh:
bash # in your custom path you need to have a plugins folder and in there you clone the repository as zsh_codex export ZSH_CUSTOM=yourcustompath source $ZSH_CUSTOM/plugins/zsh_codex/zsh_codex.plugin.zsh bindkey ^X create_completion
- Using oh-my-zsh:
- Create a file called openaiapirc in ~/.config with your SECRET_KEY.
bash [openai] secret_key = ...
Or create a file called geminiapirc in ~/.config with your SECRET_KEY.
bash [gemini] api_key = ...
- You can also optionally specify organization, base_url, model, and temperature.
- Set the LLM which you are going to use (you can choose between openai and gemini).
bash nano ~/.oh-my-zsh/custom/plugins/zsh_codex/zsh_codex.plugin.zsh # Set the api variable to openai or gemini.
- Run zsh, start typing, and complete it using ^X!
- If you use virtual environments, you can set ZSH_CODEX_PYTHON to the python executable where either openai or google-generativeai is installed.
bash export ZSH_CODEX_PYTHON=$HOME/miniconda3/bin/python
Fig Installation
Troubleshooting
Common Issues
- Unhandled ZLE widget create_completion: If you encounter this error, it can be due to your bindkey settings. Make sure to add the line:
zle -N create_completion
before you call bindkey but after loading the plugin.
- Already exists and is not an empty directory: If this error occurs when you are trying to clone the repository, it indicates that the destination path is already occupied. To fix this, try downloading the ZSH plugin again:
git clone https://github.com/tom-doerr/zsh_codex.git ~/.oh-my-zsh/custom/plugins/zsh_codex
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
Final Thoughts
These simple commands and plugin integration can significantly boost your coding efficiency by leveraging AI directly in your command line. Just think of it as having a talented assistant ready to write code for you as soon as a variable name or comment is given!
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.