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

# Hop CLI Completions

> Hop CLI supports tab completion for bash, zsh and fish

To enable tab completion, run the following command:

```bash theme={null}
hop completions  <shell> > /some/path/to/hop-completion
```

where `<shell>` is one of `bash`, `zsh` or `fish`.

<Tip>
  If you get permission denied error, you can try running the following command:
</Tip>

```bash theme={null}
# pipe output to sudo tee and do not output to the tty
$ hop completions <shell> | sudo tee /some/path/to/hop-completion > /dev/null
```

The commands above will output the completion script to the specified path.
Which will look something like this:

```bash theme={null}
$ hop completions zsh
#compdef hop

autoload -U is-at-least

_hop() {
    typeset -A opt_args
    typeset -a _arguments_options
    local ret=1

...

_hop "$@"
```

<Note>
  The correct method of installing a completion script can depend on both your
  shell and your configuration.
</Note>

## Installation

Completions typically will be installed automatically by your shell's package
manager and the script will *try* to install them.

#### Zsh

This example shows how to enable tab completion for zsh, it assumes you are
using `oh-my-zsh`.

```bash theme={null}
$ hop completions zsh > ~/.oh-my-zsh/completions/_hop
```

<Note>
  Your completion script must have the name in the format of \_ followed by the
  name of the application.
</Note>

Without `oh-my-zsh`, you will need to add a path for completion scripts to your
function path, and turn on completion script autoloading. First, add these lines
to `~/.zshrc`:

```
fpath=(~/.zsh/completion $fpath)
autoload -U compinit
compinit
```

Next, create a directory at `~/.zsh/completion` and copy the completion script
to the new directory.

#### Bash

If you have [bash-completion](https://github.com/scop/bash-completion)
installed, you can just copy your new completion script to the
`/usr/local/etc/bash_completion.d` or `/usr/share/bash-completion/completions`
directory using the following command:

```bash theme={null}
$ hop completions bash > /usr/local/etc/bash_completion.d/hop
```

Without bash-completion, you will need to source the completion script directly.
Copy it to a directory such as `~/.bash_completions/`, and then add the
following line to `~/.bash_profile` or `~/.bashrc`:

```bash theme={null}
$ source ~/.bash_completions/hop
```

#### Fish

To enable tab completion for fish, copy the completion script to the
`~/.config/fish/completions` or `/usr/share/fish/completions` directory using
the following command:

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