Skip to content

AI-powered Zsh plugin that autocompletes terminal commands using OpenAI, Ollama, Gemini and more.

License

Notifications You must be signed in to change notification settings

lgdevlop/zsh-ai-complete

Repository files navigation

zsh-ai-complete

zsh-ai-complete Logo

Complete Zsh commands using real-time AI ✨
Supports OpenAI, Ollama, Gemini, and other configurable models.

Contributions Welcome Changelog Available


🔍 About

zsh-ai-complete is a Zsh plugin that brings artificial intelligence to your terminal. It suggests and completes Zsh commands in real time using natural language or partial input.

  • 🤖 Works with OpenAI, Ollama, Gemini, and more
  • ⚡ Instant AI-powered command suggestions
  • 🔄 Switch providers live with Ctrl+E
  • 🔐 Local config file with API tokens and preferences

⚙️ Requirements

Make sure the following tools are installed on your system:

Tool Purpose Link
fzf Interactive search UI Link
curl API requests Link
jq JSON parsing Link
bat Syntax-highlighted command preview Link
fd Optional, for file previews Link

🚀 Installation

Manual

git clone https://github.com/lgdevlop/zsh-ai-complete.git ~/.zsh-ai-complete
echo "source ~/.zsh-ai-complete/zsh-ai-complete.plugin.zsh" >> ~/.zshrc
source ~/.zshrc

Zinit

zinit light lgdevlop/zsh-ai-complete

Antigen

antigen bundle lgdevlop/zsh-ai-complete

Oh My Zsh (manual plugin)

git clone https://github.com/lgdevlop/zsh-ai-complete.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-ai-complete

Then add to your .zshrc:

plugins=(git zsh-ai-complete)

Reload with:

omz reload   # if using Oh My Zsh
# or
source ~/.zshrc

🛠 Configuration

On first use, the plugin creates:

~/.config/zsh-ai-complete/ai-providers.json

Based on the example:

example.ai-providers.json

Customize it with your tokens and preferences:

{
  "openai": {
    "url": "https://api.openai.com/v1/chat/completions",
    "token": "your_api_key",
    "model": "gpt-4",
    "system_message": "You must output exactly five complete zsh commands. No explanations, no comments, no code blocks, no numbering, no blank lines. Output only the commands, one per line.",
    "output_path": ".choices[0].message.content"
  }
}

💡 Usage

  1. Press Ctrl+U to launch the assistant (via fzf)
  2. Type a command fragment or a natural question (multi-language supported)
  3. Select one of the AI-suggested commands

Example: how do I list docker containers by name?

See project-docs/examples.md for full walkthroughs.


⌨️ Shortcuts

Key Action
Ctrl+U Launch the AI command assistant
Ctrl+E Switch between configured providers
ESC Cancel without applying a suggestion

More details in project-docs/shortcuts.md


🛣️ Roadmap

  • Support for multiple AI backends
  • Dynamic provider switching (Ctrl+E)
  • Example and shortcut documentation
  • Output theming and advanced previews
  • Cached suggestions

🤝 Contributing

Contributions are welcome! Feel free to open issues or pull requests.

See CODE_OF_CONDUCT.md.


📄 License

MIT — See LICENSE.


👤 Author

Made with ❤️ by Leonardo Gomes


✨ zsh-ai-complete — Make your terminal smarter with the power of AI!