Skip to content

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 enable OpenFaaS completion with two different commands:

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

Or:

$ 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:

$ brew install bash-completion@2

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

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

You can enable OpenFaaS completion with two different commands:

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

Or:

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

ZSH

ZSH completion is simpler, just execute the following command:

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