Configuration
Command Not Found Handler
Cookie AI CLI can be integrated with your shell environment to handle scenarios where a command is not recognized. This guide covers the integration process with Zsh and Bash shells, enabling Cookie AI CLI to suggest corrections or alternatives for unrecognized commands.
Integrating with Zsh
Zsh, a popular shell among developers, can be configured to use Cookie AI CLI when it encounters a command that it does not recognize. Follow these steps to set up the integration:
Step 1: Edit Your Zsh Configuration
Open your .zshrc
or .zprofile
file in a text editor. You can usually find these files in your home directory.
# Open .zshrc with your preferred editor
nvim ~/.zshrc
Step 2: Add the Custom Handler Function
Add the following function to your configuration file:
command_not_found_handler() {
echo "zsh: command not found: $@"
ai "zsh: command not found: $@"
}
This function will automatically invoke Cookie AI CLI when an unrecognized command is entered.
Step 3: Save and Reload
After saving the changes, reload your shell configuration:
source ~/.zshrc
Integrating with Bash
Bash users can also benefit from Cookie AI CLI's capabilities. The integration process is similar to that of Zsh.
Step 1: Edit Your Bash Configuration
Open your .bashrc
or .bash_profile
file in a text editor:
# Open .bashrc with your preferred editor
nvim ~/.bashrc
Step 2: Define the Handler Function
Insert the following function into your Bash configuration file:
command_not_found_handle() {
echo "bash: command not found: $@"
ai "bash: command not found: $@"
}
Step 3: Save and Reload
Save your changes and apply them by running:
source ~/.bashrc
Testing the Integration
To test the integration, try entering a command that does not exist in your terminal. You should see Cookie AI CLI being invoked, suggesting possible corrections or alternatives.
Troubleshooting
If the integration does not work as expected, ensure that:
- Your shell configuration files (
~/.zshrc
or~/.bashrc
) are correctly updated. - Cookie AI CLI is properly installed and accessible globally.
- There are no syntax errors in the handler functions.
For further assistance, feel free to reach out on our GitHub Issues page or join our Discord Community.
By integrating Cookie AI CLI with your shell environment, you enhance the command-line experience, making it more efficient and user-friendly.