Shell Completion

The OpenFaas CLI has a shell completion feature for Bash and ZSH.

Bash for Linux

Bash for Linux requires bash-completion, please follow their installation here.

Verify if it was installed correctly by executing the following command type _init_completion.

You can enabled OpenFaaS completion with two different commands:

  1. $ echo 'source <(faas-cli completion --shell bash)' >>~/.bashrc

Or:

  1. $ faas-cli completion --shell bash > /etc/bash_completion.d/faas-cli

Bash for MacOS

By default MacOS comes with Bash 3.2, but the completion requires version 4.1+. See this instructions to upgrade.

Also, you'll need bash-completion v2. Install with the following commands:

  1. $ brew install bash-completion@2

And add the following to your ~/.bashrc file:

  1. export BASH_COMPLETION_COMPAT_DIR="/usr/local/etc/bash_completion.d"
  2. [[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"

You can enabled OpenFaaS completion with two different commands:

  1. $ echo 'source <(faas-cli completion --shell bash)' >>~/.bashrc

Or:

  1. $ faas-cli completion --shell bash > /etc/bash_completion.d/faas-cli

ZSH

ZSH completion is simpler, just execute the following command:

  1. source <(faas-cli completion --shell zsh)