Adding Tab Completion
The Kurtosis CLI supports tab completion for bash
, zsh
, and fish
. With tab completion installed, you will be able to:
- Tab-complete subcommands (e.g. typing
kurtosis
and pressing TAB will suggest subcommands) - Tab-complete dynamic arguments, when possible (e.g. typing
kurtosis enclave inspect
and pressing TAB will try to complete with the current enclave IDs)
The process for installing tab completion is specific to each shell:
bash
- Ensure you have Bash version >= 4.1
- Print your Bash version:
echo $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:
- Print your Bash version:
- 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" - 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 tab-completion
source <(kurtosis completion bash) - On Linux, add the following to your
~/.bashrc
file:# Add Kurtosis tab-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 tab-completion to Kurtosis alias
complete -F __start_kurtosis kt - On Linux, add the following to your
~/.bashrc
file:# Add tab-completion to Kurtosis alias
complete -F __start_kurtosis kt
- On Mac, add the following to your
- Reload your shell
zsh
- Add the following to your
~/.zshrc
file:# Add Kurtosis tab-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 tab-completion to Kurtosis alias
compdef __start_kurtosis kt - Reload your shell
- If you get an error like
complete:13: command not found: compdef
, add the following to the top of your~/.zshrc
and reload your shell again:autoload -Uz compinit
compinit
fish
- Add the following to your
~/.config/fish/config.fish
file:# Add Kurtosis tab-completion
kurtosis completion fish | source - Reload your shell
manual installation
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 tab-completion, and adding thesource
command to your shell config file will enable it across shell instances.# Add Kurtosis tab-completion to your shell config file
source <(kurtosis completion bash)