Adding Command-Line Completion
The Kurtosis CLI supports command-line completion for bash
, zsh
, and fish
. With completion installed, you will be able to:
- Complete subcommands (e.g. typing
kurtosis
and pressing TAB will suggest subcommands) - Complete dynamic arguments (e.g. typing
kurtosis enclave inspect
and pressing TAB will list the names of existing enclaves if any)
The process for installing completion is specific to each shell:
- bash
- zsh
- fish
- Manual Installation
- Print your Bash version:
bash --version
- If your Bash version is less than 4.1, upgrade it:
- On Mac, upgrade Mac via Homebrew:
brew install bash
- On Linux, upgrade it via the package manager for your distro
- On Mac, upgrade Mac via Homebrew:
- Check if you have bash-completion installed:
type _init_completion
- If you get an error like
-bash: type: _init_completion: not found
, install Bash completion:- On Mac:
- Install the completion library:
brew install bash-completion@2
- Add the following to your
~/.bash_profile
:export BREW_PREFIX="$(brew --prefix)"
[[ -r "${BREW_PREFIX}/etc/profile.d/bash_completion.sh" ]] && source "${BREW_PREFIX}/etc/profile.d/bash_completion.sh" - Close and re-open your terminal window to reload your shell.
- Verify that you now have the completion installed:
type _init_completion
- Install the completion library:
- On Linux, install it using the package manager for your distro using these installation instructions
- On Mac:
- Skip this step if you are installing using Homebrew and have
bash-completion@2
installed. Otherwise, proceed to source the output ofkurtosis completion bash
in your Bash config file:- On Mac, add the following to your
~/.bash_profile
file:# Add Kurtosis command-line completion
source <(kurtosis completion bash) - On Linux, add the following to your
~/.bashrc
file:# Add Kurtosis command-line completion
source <(kurtosis completion bash)
- On Mac, add the following to your
- If you have an alias set up for Kurtosis, add completion for that as well (we'll assume the alias
kt
in the examples below):- On Mac, add the following to your
~/.bash_profile
file:# Add command-line completion to Kurtosis alias
complete -F __start_kurtosis kt - On Linux, add the following to your
~/.bashrc
file:# Add command-line completion to Kurtosis alias
complete -F __start_kurtosis kt
- On Mac, add the following to your
- Close and re-open your terminal window to reload your shell and apply the changes.
- Add the following to your
~/.zshrc
file:# Add Kurtosis command-line completion
source <(kurtosis completion zsh)
compdef _kurtosis kurtosis - If you have an alias set up for Kurtosis, add the following to your
~/.zshrc
file (we'll assume the aliaskt
in this example):# Add command-line completion to Kurtosis alias
compdef __start_kurtosis kt - Close and re-open your terminal window to reload your shell and apply the changes.
- If you get an error like
complete:13: command not found: compdef
, add the following to the top of your~/.zshrc
and close and re-open your terminal window to reload your shell:autoload -Uz compinit
compinit
- Add the following to your
~/.config/fish/config.fish
file:# Add Kurtosis command-line completion
kurtosis completion fish | source - Close and re-open your terminal window to reload your shell and apply the changes.
If necessary, tab completion can be installed manually in two steps as follows, by first generating the tab completion code (specific to the shell) and then sourcing that code into the shell.
The code needed to enable tab completion can be generated by the
kurtosis
cli by runningkurtosis completion <SHELL>
command, e.g. forbash
:kurtosis completion bash
source
ing the output of the command will enable command-line completion, and adding thesource
command to your shell config file will enable it across shell instances.# Add Kurtosis command-line completion to your shell config file
source <(kurtosis completion bash)