# Shell completion

Source: https://prontaro.com/docs/cli/completion/

Suggestions resolve locally without contacting the API, and upgrading prontaro picks up new commands and flags automatically—no need to regenerate your setup.

Homebrew installs completions for Zsh, Bash, and Fish automatically. In an interactive Bash or Fish terminal, `install.sh` offers completion for your current shell if it is not installed yet, and in Zsh it prints setup instructions.

## What Tab completes

- **Commands, flags, and services:** every subcommand, alias, and flag, including `http`, `tcp`, `forward`, and `run` after `prontaro service install --`, `uninstall --`, or `status --`.
- **Cached tunnel names:** saved tunnel names for `access`, `stop`, `rename`, `rm`, and `run`, cached locally after `prontaro ls` or launching a tunnel, shown alongside their public address and kept current automatically on `rename` and `rm`.
- **Context-aware tunnel filtering:** `prontaro run` suggests your saved tunnels while skipping names you already typed on the same command line, and `--name` filters suggestions by tunnel type (`http` tunnels for `prontaro http`, `tcp` tunnels for `prontaro tcp`).
- **Access actions and your current IP:** `prontaro access <tunnel>` completes `public`, `allow`, `remove`, and `close` with short descriptions; after `allow` or `remove`, pressing `Tab` also offers a shortcut for your last known public IPv4.
- **Known flag values without filename noise:** `--proxy-protocol` suggests `v1` and `v2`, `forward --listen` suggests `127.0.0.1`, and `--location`, `--to`, and `--ip` complete your account’s cached locations, shared or dedicated targets, and dedicated IPv4 addresses. Where a file path does not apply, `prontaro` suppresses generic filename suggestions from the current directory.

## Setup by shell

### Zsh

Load completion in your current Zsh session right away:

```zsh
source <(prontaro completion zsh)
```

For persistent setup, save the completion file into a directory on your `fpath`:

```zsh
mkdir -p ~/.zsh/completions
prontaro completion zsh > ~/.zsh/completions/_prontaro
```

Make sure `~/.zsh/completions` is added to `fpath` before `compinit` in `~/.zshrc`, then reload your shell with `exec zsh`:

```zsh
fpath=(~/.zsh/completions $fpath)
autoload -Uz compinit && compinit
```

If Zsh still serves stale completions, remove `~/.zcompdump` and run `exec zsh`. If you prefer a one-line setup without managing an extra directory, append `source <(prontaro completion zsh)` to `~/.zshrc` and run `exec zsh`.

### Bash

Bash completion requires the `bash-completion` package (usually preinstalled on Linux; on macOS, install it with `brew install bash-completion@2`).

Load completion for your current Bash session:

```bash
source <(prontaro completion bash)
```

For persistent setup, write the script into the standard user completions directory:

```bash
mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion/completions"
prontaro completion bash > "${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion/completions/prontaro"
```

Open a new terminal window (or run `source ~/.bashrc`). Alternatively, you can append `source <(prontaro completion bash)` directly to `~/.bashrc`.

### Fish

Load completion in your current Fish session:

```fish
prontaro completion fish | source
```

For persistent setup, save the script into Fish’s autoloaded completions directory:

```fish
mkdir -p ~/.config/fish/completions
prontaro completion fish > ~/.config/fish/completions/prontaro.fish
```

Fish loads files from `~/.config/fish/completions` automatically in every new shell.

### PowerShell

PowerShell completion works identically whether you type `prontaro` or `prontaro.exe`.

Load completion in your current PowerShell session:

```powershell
prontaro completion powershell | Out-String | Invoke-Expression
```

To load it automatically in every new PowerShell window, allow local profile scripts for your user if your execution policy currently blocks them (no administrator rights required):

```powershell
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
```

Then create `$PROFILE` if it does not exist yet and append the completion loader:

```powershell
if (!(Test-Path $PROFILE)) { New-Item -ItemType File -Path $PROFILE -Force | Out-Null }
Add-Content -Path $PROFILE -Value 'prontaro completion powershell | Out-String | Invoke-Expression'
```

Open a new PowerShell window to activate it.

### Homebrew

Installing via `brew install prontaro/tap/prontaro` on macOS or Linuxbrew installs completions for Zsh, Bash, and Fish automatically.

If pressing `Tab` does not suggest `prontaro` commands yet, enable Homebrew’s completions directory in your shell. For Zsh, add `site-functions` before `compinit` in `~/.zshrc` and run `exec zsh` (remove `~/.zcompdump` if an older cache lingers):

```zsh
FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"
autoload -Uz compinit && compinit
```

For Bash and Fish configuration with Homebrew, see the official [Homebrew Shell Completion guide](https://docs.brew.sh/Shell-Completion).

## Verify completion and refresh tunnel names

Because completions run offline, run `prontaro ls` once after signing in—or `prontaro ls --all` to include stopped tunnels—so your tunnel names are stored locally. Launching a tunnel (`http`, `tcp`, `run`), renaming it, or removing it updates that local list automatically.

Test completion interactively in your terminal:

```text
$ prontaro ls --all
$ prontaro access <Tab>
api     https://api-demo.prontaro.run
pg      203.0.113.10:5432
$ prontaro access pg <Tab>
allow   add allowed IPv4/CIDR or me
close   close TCP port to everyone
public  allow everyone
remove  remove IPv4/CIDR or me
```

## Next steps

- [prontaro CLI command reference](https://prontaro.com/docs/cli/commands.md) — full list of subcommands, global flags, and terminal examples.
- [Install prontaro CLI on Linux](https://prontaro.com/docs/cli/linux.md) — quick or manual installation with SHA256 verification and `systemd` setup.
- [Install prontaro CLI on macOS](https://prontaro.com/docs/cli/macos.md) — setup on Apple Silicon and Intel Macs with Homebrew, Gatekeeper, and `launchd`.
- [Install prontaro CLI on Windows](https://prontaro.com/docs/cli/windows.md) — installation via PowerShell without admin rights and Task Scheduler auto-start.
