This is a ZSH plugin that enables you to use OpenAI's Codex AI in the command line.
AI in the command line.
You just need to write a comment or variable name and the AI will write the corresponding code.
This is a ZSH plugin that enables you to use OpenAI's powerful Codex AI in the command line. OpenAI Codex is the AI that also powers GitHub Copilot. To use this plugin you need to get access to OpenAI's Codex API.
pip3 install openai
git clone https://github.com/tom-doerr/zsh_codex.git ~/.oh-my-zsh/custom/plugins/zsh_codex
.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
openaiapirc
in ~/.config
with your SECRET_KEY.[openai]
secret_key = ...
You can also optionally specify: organization, base_url, model and temperature.
Run zsh
, start typing and complete it using ^X
!
If you use virtual environments you can set ZSH_CODEX_PYTHON
to python executable where openai
is installed.
e.g. for miniconda
you can use:
export ZSH_CODEX_PYTHON="$HOME/miniconda3/bin/python"
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)
).
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