Generate

Learn how to produce auto-completion for your terminal.

Command

$ vela generate completion <parameters...> <arguments...>

Parameters

The following parameters are used to configure the command:

NameDescriptionEnvironment Variables
bashgenerate a Bash auto-completion scriptVELA_BASH, COMPLETION_BASH
zshgenerate a Zsh auto-completion scriptVELA_ZSH, COMPLETION_ZSH

Permissions

COMING SOON!

Sample

Request

vela generate completion --bash

Response

#! /bin/bash

_cli_bash_autocomplete() {
  if [[ "${COMP_WORDS[0]}" != "source" ]]; then
    local cur opts base
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"

    if [[ "$cur" == "-"* ]]; then
      opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} ${cur} --generate-bash-completion )
    else
      opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
    fi

    COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
      return 0
  fi
}

complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete vela

Permanent Automatic Completion

This section covers how to enable auto-completion for your terminal permanently.

Bash

  1. Install v2 of Bash Completion
brew install bash-completion@2
  1. Copy Vela Bash Completion script
vela generate completion --bash >> /usr/local/etc/bash_completion.d/vela.sh
  1. Update Bash Profile with Completion
export BASH_COMPLETION_COMPAT_DIR="/usr/local/etc/bash_completion.d" >> $HOME/.bash_profile
[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh" >> $HOME/.bash_profile
  1. Source Bash Profile in Current Terminal
source $HOME/.bash_profile

Zsh

  1. Update Zsh Profile with Completion
source <(vela generate completion --zsh) >> $HOME/.zshrc