> ## Documentation Index
> Fetch the complete documentation index at: https://hayate.shiina.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# hayate completions — Generate Shell Tab Completion Scripts

> hayate completions generates completion scripts for bash, zsh, fish, PowerShell, and Elvish. Tab-complete every Hayate flag and subcommand.

Shell tab completions let you press <kbd>Tab</kbd> to auto-complete `hayate` subcommands, flags, and their accepted values instead of typing them out or consulting the docs. Once installed, typing `hayate se<Tab>` expands to `hayate send`, and `hayate send --ha<Tab>` fills in `--hash`. This saves time, reduces typos, and makes it easy to explore available options without leaving your terminal. `hayate completions` generates the appropriate script for your shell so you can source it into your session or install it permanently.

## Usage

```
hayate completions <SHELL>
```

**Supported shells:** `bash`, `zsh`, `fish`, `powershell`, `elvish`

## Setup instructions

<Tabs>
  <Tab title="bash">
    Write the completion script to the standard bash-completions directory, then either restart your shell or source it immediately:

    ```bash theme={null}
    hayate completions bash > ~/.local/share/bash-completion/completions/hayate
    # Or for immediate effect in the current session:
    source <(hayate completions bash)
    ```

    If the `~/.local/share/bash-completion/completions/` directory does not exist, create it first:

    ```bash theme={null}
    mkdir -p ~/.local/share/bash-completion/completions
    ```
  </Tab>

  <Tab title="zsh">
    Write the completion script to a directory on your `fpath`, then register and initialize the completion system:

    ```bash theme={null}
    hayate completions zsh > ~/.zfunc/_hayate
    # Add to ~/.zshrc if not already present:
    fpath+=~/.zfunc
    autoload -Uz compinit && compinit
    ```

    After editing `~/.zshrc`, reload your configuration:

    ```bash theme={null}
    source ~/.zshrc
    ```
  </Tab>

  <Tab title="fish">
    Fish automatically loads completion files from `~/.config/fish/completions/`. Drop the script there and completions are active in all new shell sessions:

    ```bash theme={null}
    hayate completions fish > ~/.config/fish/completions/hayate.fish
    ```

    The completions are available immediately in new fish sessions. To apply them in your current session without restarting, run:

    ```fish theme={null}
    source ~/.config/fish/completions/hayate.fish
    ```
  </Tab>

  <Tab title="PowerShell">
    Pipe the completion script directly into your current session using `Invoke-Expression`:

    ```powershell theme={null}
    hayate completions powershell | Out-String | Invoke-Expression
    ```

    To persist completions across all sessions, append the one-liner to your PowerShell profile:

    ```powershell theme={null}
    # Append to your $PROFILE (creates the file if it does not exist)
    Add-Content -Path $PROFILE -Value "`nhayate completions powershell | Out-String | Invoke-Expression"
    ```

    If your profile does not exist yet, create it first:

    ```powershell theme={null}
    New-Item -ItemType File -Force -Path $PROFILE
    ```
  </Tab>

  <Tab title="Elvish">
    Write the completion module to Elvish's library directory:

    ```bash theme={null}
    hayate completions elvish > ~/.config/elvish/lib/hayate.elv
    ```

    Then import the module in your `~/.config/elvish/rc.elv`:

    ```bash theme={null}
    echo "use hayate" >> ~/.config/elvish/rc.elv
    ```
  </Tab>
</Tabs>

<Note>
  After installing a completion script to a file, you need to **start a new
  shell session** (or source the file explicitly) before tab completion takes
  effect. Changes to `~/.zshrc`, `~/.bashrc`, or your PowerShell `$PROFILE` are
  not applied to the current session automatically.
</Note>
