Tools / CLI / Get started

Set up command completion

Command completion makes working with the CLI easier. Instead of typing the full command, enter the first letters and press the Tab key. With completion, this automatically enters the complete command or you get a list of suggestions.

Homebrew

If you installed the Algolia CLI with Homebrew, and you’ve set up shell completion, command completion for the Algolia CLI should already work.

Bash

Command completion depends on the bash-completion package. If it isn’t installed already, you can install it with your favorite package manager. For example, with Homebrew, run: brew install bash-completion@2.

To enable completion in the current session, run:

1
source <(algolia completion bash)

To enable command completion for every new session, run:

1
algolia completion bash > /etc/bash_completion.d/algolia

Start a new Bash session to explore the completions.

Setup for Zsh

If you didn’t set up shell completion in Zsh already, add the following to your .zshrc file, or run the commands in the current session:

1
echo "autoload -U compinit; compinit" >> ~/.zshrc

To enable completion in the current session, run:

1
eval "$(algolia completion zsh)"

To enable command completion for every new session, run:

1
algolia completion zsh > "${fpath[1]}/_algolia"

Start a new Zsh session to explore the completions.

You might want to put the completion script into a directory in your profile, for example ~/.local/share/zsh/site-functions. Then, add fpath=(~/.local/share/zsh/site-functions $fpath) to your .zshrc file.

Fish

To enable command completion in the current session, run:

1
algolia completion fish | source

To enable command completion for every new session:

1
algolia completion fish > ~/.config/fish/completions/algolia.fish

Start a new Fish session to explore the completions.

PowerShell

To enable command completion in the current session, run:

1
algolia completion powershell | Out-String | Invoke-Expression

To enable command completion for PowerShell for every new session, add the output of the previous command to your PowerShell profile.

Did you find this page helpful?