# Install Shell Completions

> Add tab completion for bash, zsh or fish, so your shell completes Testlane's verbs, your project names and the workspaces you have.

By the end of this guide, pressing `Tab` after `testlane` completes its verbs, your project names and the slugs of the workspaces you already have. You'll type less, and you'll stop guessing whether a workspace is called `pr-42` or `feat-login`.

## Before you start

You'll need Testlane [installed](https://testlane.dev/docs/getting-started/installation) and bash, zsh or fish, the three shells it writes completions for.

## Turn on completion

::steps{level="3"}

### Install the script for your shell

`testlane completions <shell>` prints a completion script on stdout. In bash and fish, you load it from the file your shell runs at startup. zsh loads completion functions from the directories on its `fpath`, so for zsh you write the script to a file once and add that directory:

:::code-group

```bash [bash]
# ~/.bashrc
eval "$(testlane completions bash)"
```

```bash [zsh]
# Run once in a terminal:
mkdir -p ~/.zsh/completions
testlane completions zsh > ~/.zsh/completions/_testlane

# Then in ~/.zshrc, before compinit runs
# (keep your own compinit line if you have one):
fpath=(~/.zsh/completions $fpath)
autoload -Uz compinit && compinit
```

```bash [fish]
# ~/.config/fish/config.fish
testlane completions fish | source
```

:::

### Open a new shell

Open a new terminal, so your shell runs its startup file again. To load it in the terminal you have, run the file yourself, like this for zsh:

```bash
source ~/.zshrc
```

### Try it

Type `testlane `, with the space, and press `Tab`. Your shell offers the top-level verbs and your project names. After a project, it offers the verbs and that project's workspace slugs.

::

## What it completes

The script completes three things, depending on where you are in the command:

| Where you are             | What it offers                                                                     |
| ------------------------- | ---------------------------------------------------------------------------------- |
| The first word            | The top-level verbs and your project names                                         |
| After a project name      | The project verbs, the workspace verbs and the slugs of that project's workspaces |
| After anything else       | The project verbs and the workspace verbs                                          |

The top-level verbs are `setup`, `projects`, `doctor`, `config`, `completions`, `help`, `version` and `mcp`. The project verbs are `list`, `clean` and `ps`, and the workspace verbs are `checkout`, `code`, `run`, `exec`, `shell`, `sync`, `diff`, `info`, `rm`, `start`, `stop` and `logs`.

Your project names are written into the script when it's generated, so a project you add later needs a new script. For bash and fish, a new shell is enough, since the startup file generates the script each time. For zsh, run the `testlane completions zsh > ~/.zsh/completions/_testlane` command again, since the file keeps the project names it was written with. The slugs are looked up while you type, since the script runs `testlane <project> list --json`, so new workspaces show up straight away.

## When it fails

`completions` writes scripts for bash, zsh and fish only, so any other shell is a usage error, `E_USAGE` (exit `2`):

```bash
testlane completions ksh
```

```
error(E_USAGE): unsupported shell 'ksh'
hint: one of: bash, zsh, fish
```

Leaving the shell out fails the same way:

```
error(E_USAGE): completions requires a shell
hint: one of: bash, zsh, fish
```

## Where to go next

Here's where to go from here:

- [Top-level verbs](https://testlane.dev/docs/cli/top-level-verbs) has `completions` with the other top-level verbs.
- [Workspace verbs](https://testlane.dev/docs/cli/workspace-verbs) explains every verb the script completes after a workspace.
- [Exit codes](https://testlane.dev/docs/cli/exit-codes) lists what each exit code means.
