Surveyor

Shell completion

The installers set up tab completion for spice in Bash, Zsh and PowerShell. The completion script is generated by the installed CLI, so it offers the commands your installation has. Choose your shell above the recording to see how it looks there.

Edition
Shell
  1. Type spice and ask the shell for completions. Press Tab twice. Press Tab once.

  2. Zsh lists the top-level commands on the first Tab. On the second it starts inserting them in turn, so config is now on the line. Keep pressing Tab to move through the list, or type a few letters to narrow it.

    Bash lists the top-level commands on the second Tab and leaves the line as it was, ready for you to type the first letters of the one you want.

    PowerShell lists the top-level commands and options on the first Tab. That is its behavior on macOS and Linux; on Windows, Tab instead cycles through the candidates in place.

  3. It works at every level: spice survey followed by Tab offers the survey types.

    The candidates come from spice generate-completion, which reads the installed CLI, so they always match the commands and survey types you have.

    The candidates come from the script the installer generated with spice generate-powershell-completion.

Set it up by hand

The installers do this for you. To do it yourself, for example after an upgrade:

  • Bash. Write the script with spice generate-completion > ~/.spice-completion.bash, and source that file from ~/.bashrc.
  • Zsh. Use the same script, loaded through Bash compatibility. In ~/.zshrc, add autoload -U +X bashcompinit && bashcompinit, then source the file.
  • PowerShell. Write the script with spice generate-powershell-completion > spice-completion.ps1, and dot-source it from your $PROFILE.