Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Completions Subcommand

The completions command provides scripts to generate autocompletion functions for bash and zsh shells. How they are used depends on the shell in use. To determine which shell is being used, you can run echo $0 in a terminal.

Running either gda completions zsh or gda completions bash will generate a script used by the shell to provide autocompletion suggestions when running gda commands.

Setting up completions

The way to enable completions depends on the shell being used.

Bash

The command can be run directly so the generated script can be reviewed but to setup completions the script should be sourced in the current shell.

$ source <(gda completions bash)

This can be automated by including the line in a script that is sourced at start-up, for instance ~/.bashrc. This will require gda to already be on the path so it may be useful wrap the call so it is only run if gda is available.

if [[ $(command -v gda >/dev/null) ]]; then
    source <(gda completions bash)
fi

Zsh

The generated script can be reviewed by running the completions command directly, but to setup completions the script should be written to a file called _gda in a directory on the shell's fpath. A possible setup is below although it assumes no existing configuration and should be modified to match user's existing configuration.

$ mkdir -p ~/.zsh/completions
$ gda completions zsh > ~/.zsh/completions/_gda
$ echo "fpath=(~/.zsh/completions $fpath)" >> ~/.zshrc
$ echo "autoload -Uz compinit && compinit" >> ~/.zshrc

For a full explanation of the completion setup see the ZSH docs

Help

These setup up instructions are also available via gda completions --help
$ gda completions --help
Generate autocompletion scripts for use with the gda CLI

For Bash, enable the completions by running

    $ source <(gda completions bash)

This can be automated by adding to a bash startup script somewhere (.bashrc etc)

For zsh, the completions can be enabled by writing the script to a file in one
of the directories in your `$fpath` variable. This can be set up in your .zshrc
file via something like `fpath+=~/.zsh/completions`

    $ gda completions zsh > ~/.zsh/completions/_gda

`compinit` will then need to be run although this is often already run during
startup.

Usage: gda completions <SHELL>

Arguments:
  <SHELL>
          Shell to generate completions for
          
          [possible values: bash, zsh]

Options:
  -h, --help
          Print help (see a summary with '-h')