# ZSH Completion for Shell GPT CLI (`sgpt` command) This ZSH completion script enhances your command line interface by providing auto-completion for the [`sgpt`](https://github.com/TheR1D/shell_gpt) command, part of the Shell GPT suite. It supports all subcommands and their options, significantly improving efficiency and reducing the need for memorizing syntax. ## Installation 1. **Download the Completion Script** You can download the `_sgpt` script directly using the following command: ```bash mkdir -p $HOME/.zsh_completions wget -O $HOME/.zsh_completions/_sgpt https://gist.github.com/obeone/dc66f2ca40b8254edab61ac50cdec0f3/raw/_sgpt.zsh ``` 2. **Add to ZSH Fpath** Ensure that the script is in one of the directories listed in your `fpath`. You can view your current `fpath` with: ```bash echo $fpath ``` To add a new directory to your `fpath`, include the following line in your `.zshrc`: ```bash fpath=($HOME/.zsh_completions $fpath) ``` 3. **Source the Completion Script** > To enable the completion script, restart your ZSH session or source your `.zshrc` file if you haven't done so since updating it `source ~/.zshrc` > If you use Oh My Zsh, you can reload it with `omz reload`. ZSH should automatically source all completion scripts in your `fpath` when starting a new shell session. Ensure the script is named correctly as `_sgpt`. ## Usage Simply type `sgpt` followed by a space and a `-`, then press `tab` to see available subcommands and options. For example: ```bash sgpt -[tab] # Lists all subcommands sgpt --model [tab] # Will propose available models ``` ## How It Was Created The completion script for `sgpt` was primarily generated using a custom GPT model I created named [ZSH Expert](https://chatgpt.com/g/g-XczdbjXSW-zsh-expert) (you need ChatGPT Plus to use it). **This model specializes in creating ZSH completion scripts** by analyzing the `--help` outputs of various commands. Here's the process: 1. **Generating Completion Logic:** I provided the `--help` outputs of the `sgpt` command to ZSH Expert, which then generated the necessary ZSH completion logic, including handling of subcommands and options. 2. **Validation and Iteration:** The script was tested iteratively to catch any issues with command completion, especially around new or complex command options. Feel free to report any issues to help improve the script further. You can view the entire creation process and the discussions that led to the final script in this [chat history](https://chatgpt.com/share/2e375594-bc69-4403-9e48-f0fe8faeb542?oai-dm=1). ## Contributors - **[ZSH Expert](https://chatgpt.com/g/g-XczdbjXSW-zsh-expert)** (ChatGPT Custom GPT, did almost all the job) - **[obeone](https://github.com/obeone)** (Guiding and testing) ## License Distributed under the MIT License.